Documentation
¶
Index ¶
- Variables
- func BadExit(msg string, err error)
- func Defer(dur time.Duration, f func())
- func ExitWatchdog()
- func GetAPPNAME() string
- func GetCmd() string
- func GoodExit(msg string)
- func Init(dest any, APPNAME string, anyString string, VERSION string)
- func Len() int
- func MakeAutocompleteFiles(argname string)
- func MakeBashCompleteFiles(argname string)
- func MakeZshCompleteFiles(argname string)
- func Real() []string
- func RunIfTakesLonger(d time.Duration, f func()) (cancel func())
- func Version() string
- type App
- type AppScanner
- type ArgTree
- type ArgTreeScanner
- type ArgsBash
- type Argv
- func (*Argv) Descriptor() ([]byte, []int)deprecated
- func (v *Argv) FormatJSON() string
- func (v *Argv) FormatTEXT() string
- func (x *Argv) GetAppInfo() *App
- func (x *Argv) GetArgs() []string
- func (x *Argv) GetArgvDuration() *durationpb.Duration
- func (pb *Argv) GetCmd() string
- func (x *Argv) GetCtime() *timestamppb.Timestamp
- func (x *Argv) GetDuration() *durationpb.Duration
- func (x *Argv) GetErrCounter() int32
- func (x *Argv) GetFast() int32
- func (x *Argv) GetOutCounter() int32
- func (x *Argv) GetPartial() string
- func (x *Argv) GetReal() []string
- func (x *Argv) GetStddbg() string
- func (x *Argv) GetStderr() string
- func (x *Argv) GetStdout() string
- func (x *Argv) GetSubcmd() string
- func (x *Argv) GetUuid() string
- func (pb *Argv) Gui() bool
- func (pb *Argv) IsMatch(match string) bool
- func (v *Argv) Marshal() ([]byte, error)
- func (v *Argv) MarshalJSON() ([]byte, error)
- func (*Argv) ProtoMessage()
- func (x *Argv) ProtoReflect() protoreflect.Message
- func (x *Argv) Reset()
- func (x *Argv) String() string
- func (v *Argv) Unmarshal(data []byte) error
- func (v *Argv) UnmarshalJSON(data []byte) error
- func (v *Argv) UnmarshalTEXT(data []byte) error
- func (pb *Argv) Version() string
- type ArgvScanner
- type Argvs
- func (x *Argvs) All() *ArgvScanner
- func (x *Argvs) Append(y *Argv)
- func (x *Argvs) Clone(y *Argv) *Argv
- func (x *Argvs) Delete(y *Argv) bool
- func (*Argvs) Descriptor() ([]byte, []int)deprecated
- func (v *Argvs) FormatJSON() string
- func (v *Argvs) FormatTEXT() string
- func (x *Argvs) GetArgvs() []*Argv
- func (x *Argvs) GetFilename() string
- func (x *Argvs) GetUuid() string
- func (x *Argvs) GetVersion() string
- func (x *Argvs) IterAll() iter.Seq[*Argv]
- func (x *Argvs) Len() int
- func (pb *Argvs) Load() error
- func (v *Argvs) Marshal() ([]byte, error)
- func (v *Argvs) MarshalJSON() ([]byte, error)
- func (*Argvs) ProtoMessage()
- func (x *Argvs) ProtoReflect() protoreflect.Message
- func (x *Argvs) Reset()
- func (pb *Argvs) Save() error
- func (x *Argvs) String() string
- func (v *Argvs) Unmarshal(data []byte) error
- func (v *Argvs) UnmarshalJSON(data []byte) error
- func (v *Argvs) UnmarshalTEXT(data []byte) error
- type ArgvsScanner
- type AutoType
- type ExitCode
- type GuiPrep
- type StringWriter
- type StructEntry
- func (*StructEntry) Descriptor() ([]byte, []int)deprecated
- func (x *StructEntry) GetDefaultVal() string
- func (x *StructEntry) GetHelpText() string
- func (x *StructEntry) GetMatchText() string
- func (x *StructEntry) GetStructName() string
- func (x *StructEntry) GetStructType() string
- func (*StructEntry) ProtoMessage()
- func (x *StructEntry) ProtoReflect() protoreflect.Message
- func (x *StructEntry) Reset()
- func (x *StructEntry) String() string
- type StructEntryScanner
Constants ¶
This section is empty.
Variables ¶
var File_argv_proto protoreflect.FileDescriptor
Functions ¶
func ExitWatchdog ¶ added in v0.0.32
func ExitWatchdog()
this code doesn't need to be this complicated. I put it here as reference code for myself so I could remember where it is.
func MakeAutocompleteFiles ¶ added in v0.0.33
func MakeAutocompleteFiles(argname string)
func MakeBashCompleteFiles ¶ added in v0.0.33
func MakeBashCompleteFiles(argname string)
func MakeZshCompleteFiles ¶ added in v0.0.33
func MakeZshCompleteFiles(argname string)
func RunIfTakesLonger ¶ added in v0.0.46
RunIfTakesLonger schedules a function `f` to run after a duration `d`. It returns a "cancel" function. If the cancel function is called before the duration `d` has passed, the scheduled function `f` will not be executed.
This is designed to be used with defer, like so:
func myFunc() {
cancel := RunIfTakesLonger(time.Second, func() {
fmt.Println("myFunc took more than a second!")
})
defer cancel()
// ... rest of the function
}
Types ¶
type App ¶ added in v0.0.41
type App struct {
APPNAME string `protobuf:"bytes,1,opt,name=APPNAME,proto3" json:"APPNAME,omitempty"`
VERSION string `protobuf:"bytes,2,opt,name=VERSION,proto3" json:"VERSION,omitempty"`
BUILDTIME string `protobuf:"bytes,3,opt,name=BUILDTIME,proto3" json:"BUILDTIME,omitempty"`
// contains filtered or unexported fields
}
func (*App) Descriptor
deprecated
added in
v0.0.41
func (*App) GetAPPNAME ¶ added in v0.0.41
func (*App) GetBUILDTIME ¶ added in v0.0.41
func (*App) GetVERSION ¶ added in v0.0.41
func (*App) ProtoMessage ¶ added in v0.0.41
func (*App) ProtoMessage()
func (*App) ProtoReflect ¶ added in v0.0.41
func (x *App) ProtoReflect() protoreflect.Message
type AppScanner ¶ added in v0.0.41
func (*AppScanner) Next ¶ added in v0.0.41
func (it *AppScanner) Next() *App
Next() returns the next thing in the array
func (*AppScanner) Scan ¶ added in v0.0.41
func (it *AppScanner) Scan() bool
type ArgTree ¶ added in v0.0.46
type ArgTree struct {
Structs []*StructEntry `protobuf:"bytes,1,rep,name=Structs,proto3" json:"Structs,omitempty"` // a tree of the argv structs in argv.go
MainArgvName string `protobuf:"bytes,2,opt,name=mainArgvName,proto3" json:"mainArgvName,omitempty"` // name to use in main.go
// contains filtered or unexported fields
}
func (*ArgTree) Descriptor
deprecated
added in
v0.0.46
func (*ArgTree) GetMainArgvName ¶ added in v0.0.46
func (*ArgTree) GetStructs ¶ added in v0.0.46
func (x *ArgTree) GetStructs() []*StructEntry
func (*ArgTree) ProtoMessage ¶ added in v0.0.46
func (*ArgTree) ProtoMessage()
func (*ArgTree) ProtoReflect ¶ added in v0.0.46
func (x *ArgTree) ProtoReflect() protoreflect.Message
type ArgTreeScanner ¶ added in v0.0.46
func (*ArgTreeScanner) Next ¶ added in v0.0.46
func (it *ArgTreeScanner) Next() *ArgTree
Next() returns the next thing in the array
func (*ArgTreeScanner) Scan ¶ added in v0.0.46
func (it *ArgTreeScanner) Scan() bool
type ArgsBash ¶ added in v0.0.3
type ArgsBash struct {
Bash bool `arg:"--bash" help:"generate bash completion"`
}
var ArgvBash ArgsBash
this is sill in development figure out how to trigger this
type Argv ¶ added in v0.0.39
type Argv struct {
Ctime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=ctime,proto3" json:"ctime,omitempty"` // set at the start of argv.Init()
Duration *durationpb.Duration `protobuf:"bytes,2,opt,name=duration,proto3" json:"duration,omitempty"` // could mean lots of things
ArgvDuration *durationpb.Duration `protobuf:"bytes,3,opt,name=argvDuration,proto3" json:"argvDuration,omitempty"` // how long autocomplete & match took
AppInfo *App `protobuf:"bytes,4,opt,name=appInfo,proto3" json:"appInfo,omitempty"`
Args []string `protobuf:"bytes,5,rep,name=args,proto3" json:"args,omitempty"` // a copy of os.Args
Real []string `protobuf:"bytes,6,rep,name=real,proto3" json:"real,omitempty"` // what will really be sent to the application
Subcmd string `protobuf:"bytes,7,opt,name=subcmd,proto3" json:"subcmd,omitempty"` // the subcommand being processed. For "git pull <tab>", cmd would be "pull"
Partial string `protobuf:"bytes,8,opt,name=partial,proto3" json:"partial,omitempty"` // if the user has only partially inputed something
Fast int32 `protobuf:"varint,9,opt,name=fast,proto3" json:"fast,omitempty"` // is autocomplete running quickly?
Stdout string `protobuf:"bytes,10,opt,name=stdout,proto3" json:"stdout,omitempty"` // all output is loaded here before being sent to the shell
Stderr string `protobuf:"bytes,11,opt,name=stderr,proto3" json:"stderr,omitempty"` // all output is loaded here before being sent to the shell
Stddbg string `protobuf:"bytes,12,opt,name=stddbg,proto3" json:"stddbg,omitempty"` // all output is loaded here before being sent to the shell
OutCounter int32 `protobuf:"varint,13,opt,name=outCounter,proto3" json:"outCounter,omitempty"` // counter to track if the help text has been sent to Stderr
ErrCounter int32 `protobuf:"varint,14,opt,name=errCounter,proto3" json:"errCounter,omitempty"` // counter to track if the help text has been sent to Stderr
Uuid string `protobuf:"bytes,15,opt,name=uuid,proto3" json:"uuid,omitempty"` // all output is loaded here before being sent to the shell
// contains filtered or unexported fields
}
var PB *Argv
try a global here to see how that turns out
func Autocomplete ¶ added in v0.0.39
func Autocomplete() *Argv
This function behaves oddly. It works in several different ways. It can:
- Initialize a protobuf and returns it to the application
- Help a user generate shell completion support & os.Exit
- figures out what to print to Stdout & Stderr and then does os.Exit()
func (*Argv) Descriptor
deprecated
added in
v0.0.39
func (*Argv) FormatTEXT ¶ added in v0.0.39
apparently this isn't stable, but it's awesomely better https://protobuf.dev/reference/go/faq/#unstable-text it's brilliant for config files!
func (*Argv) GetAppInfo ¶ added in v0.0.42
func (*Argv) GetArgvDuration ¶ added in v0.0.49
func (x *Argv) GetArgvDuration() *durationpb.Duration
func (*Argv) GetCtime ¶ added in v0.0.39
func (x *Argv) GetCtime() *timestamppb.Timestamp
func (*Argv) GetDuration ¶ added in v0.0.39
func (x *Argv) GetDuration() *durationpb.Duration
func (*Argv) GetErrCounter ¶ added in v0.0.49
func (*Argv) GetOutCounter ¶ added in v0.0.49
func (*Argv) GetPartial ¶ added in v0.0.39
func (*Argv) MarshalJSON ¶ added in v0.0.39
marshal json
func (*Argv) ProtoMessage ¶ added in v0.0.39
func (*Argv) ProtoMessage()
func (*Argv) ProtoReflect ¶ added in v0.0.39
func (x *Argv) ProtoReflect() protoreflect.Message
func (*Argv) UnmarshalJSON ¶ added in v0.0.39
unmarshal json
func (*Argv) UnmarshalTEXT ¶ added in v0.0.39
unmarshalTEXT. This reads the .text config file back in after the user edits it
type ArgvScanner ¶ added in v0.0.39
func (*ArgvScanner) Next ¶ added in v0.0.39
func (it *ArgvScanner) Next() *Argv
Next() returns the next thing in the array
func (*ArgvScanner) Scan ¶ added in v0.0.39
func (it *ArgvScanner) Scan() bool
type Argvs ¶ added in v0.0.39
type Argvs struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:1e6e765c-0c77-4c81-a622-0d819bfcce9a`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.6`
Argvs []*Argv `protobuf:"bytes,3,rep,name=argvs,proto3" json:"argvs,omitempty"`
Filename string `protobuf:"bytes,4,opt,name=filename,proto3" json:"filename,omitempty"` // `autogenpb:save` -- this enables autogenerated pb.Load() and pb.Save()
// contains filtered or unexported fields
}
func (*Argvs) All ¶ added in v0.0.39
func (x *Argvs) All() *ArgvScanner
func (*Argvs) Append ¶ added in v0.0.39
a Append() shortcut (that does Clone() with a mutex) notsure if it really works doesn't allow nil
func (*Argvs) Clone ¶ added in v0.0.39
a Clone() shortcut (with a mutex). notsure if it really works
func (*Argvs) Descriptor
deprecated
added in
v0.0.39
func (*Argvs) FormatTEXT ¶ added in v0.0.39
apparently this isn't stable, but it's awesomely better https://protobuf.dev/reference/go/faq/#unstable-text it's brilliant for config files!
func (*Argvs) GetFilename ¶ added in v0.0.39
func (*Argvs) GetVersion ¶ added in v0.0.39
func (*Argvs) IterAll ¶ added in v0.0.39
Iterate 'for x := range' syntax using the awesome golang 1.24 'iter'
func (*Argvs) MarshalJSON ¶ added in v0.0.39
marshal json
func (*Argvs) ProtoMessage ¶ added in v0.0.39
func (*Argvs) ProtoMessage()
func (*Argvs) ProtoReflect ¶ added in v0.0.39
func (x *Argvs) ProtoReflect() protoreflect.Message
func (*Argvs) UnmarshalJSON ¶ added in v0.0.39
unmarshal json
func (*Argvs) UnmarshalTEXT ¶ added in v0.0.39
unmarshalTEXT. This reads the .text config file back in after the user edits it
type ArgvsScanner ¶ added in v0.0.39
func (*ArgvsScanner) Next ¶ added in v0.0.39
func (it *ArgvsScanner) Next() *Argvs
Next() returns the next thing in the array
func (*ArgvsScanner) Scan ¶ added in v0.0.39
func (it *ArgvsScanner) Scan() bool
type AutoType ¶ added in v0.0.46
type AutoType struct {
Err error // store any errors from argv
Argv func([]string) // the function for shell autocomplete
// contains filtered or unexported fields
}
this is a work in progress
type ExitCode ¶ added in v0.0.38
type ExitCode int
const ( ExitSuccess ExitCode = 0 // the program completed its task without errors. ExitFailure ExitCode = 1 // generic, catch-all code for "something went wrong." ExitUsage ExitCode = 64 // EX_USAGE: user provided invalid command-line arguments or flags. ExitDataErr ExitCode = 65 // EX_DATAERR: input data was incorrect or malformed. ExitNoInput ExitCode = 66 // EX_NOINPUT: an input file was not found or could not be read. ExitNoUser ExitCode = 67 // EX_NOUSER: a specified user did not exist. ExitNoHost ExitCode = 68 // EX_NOHOST: a specified host did not exist. ExitSoftware ExitCode = 70 // EX_SOFTWARE: internal software error. bugs ("this should never happen") ExitOSErr ExitCode = 71 // EX_OSERR: an operating system error, such as a failed system call. ExitOSFile ExitCode = 72 // EX_OSFILE: a critical OS file is missing or corrupt. (e.g., /etc/passwd) ExitCantCreate ExitCode = 73 // EX_CANTCREATE: a user-specified output file could not be created. ExitIOErr ExitCode = 74 // EX_IOERR: an error occurred during an I/O operation. ExitTempFail ExitCode = 75 // EX_TEMPFAIL: temporary failure. The user is invited to retry. ExitProtocol ExitCode = 76 // EX_PROTOCOL: protocol error during network communication. ExitNoPerm ExitCode = 77 // EX_NOPERM: the user does not have sufficient filesystem permissions. ExitConfig ExitCode = 78 // EX_CONFIG: something is wrong in a configuration file. Exit126 ExitCode = 126 // Reserved for shell (command not executable) Exit127 ExitCode = 127 // Reserved for shell (command not found) Exit128 ExitCode = 128 // Reserved for shell (termination by a signal) ExitPB ExitCode = 252525 // NEW FOR ARGV: return a protobuf on exit. todo: need someone to make an RFC for this Exit109 ExitCode = 109 // for testing argv. 109 = 252525 % 256 )
type StringWriter ¶ added in v0.0.46
type StringWriter struct {
// contains filtered or unexported fields
}
StringWriter is a custom type that implements the io.Writer interface for a string variable. It holds a pointer to the string it will write to.
var Stddbg *StringWriter // argv writes it's internal debugging output here
var Stderr *StringWriter // bash dumps this as "help" about application options
var Stdout *StringWriter // bash uses this to match strings
func NewStringWriter ¶ added in v0.0.46
func NewStringWriter(s *string) *StringWriter
NewStringWriter creates a new StringWriter that writes to the provided string pointer.
type StructEntry ¶ added in v0.0.46
type StructEntry struct {
StructName string `protobuf:"bytes,1,opt,name=structName,proto3" json:"structName,omitempty"` // 'Force', 'Verbose', 'SortCmd'
StructType string `protobuf:"bytes,2,opt,name=structType,proto3" json:"structType,omitempty"` // 'string', 'int', '[]string', '*FindCmd'
DefaultVal string `protobuf:"bytes,3,opt,name=defaultVal,proto3" json:"defaultVal,omitempty"` // "true"
HelpText string `protobuf:"bytes,4,opt,name=helpText,proto3" json:"helpText,omitempty"` // "This will help you"
MatchText string `protobuf:"bytes,5,opt,name=matchText,proto3" json:"matchText,omitempty"` // "--help-me
// contains filtered or unexported fields
}
func (*StructEntry) Descriptor
deprecated
added in
v0.0.46
func (*StructEntry) Descriptor() ([]byte, []int)
Deprecated: Use StructEntry.ProtoReflect.Descriptor instead.
func (*StructEntry) GetDefaultVal ¶ added in v0.0.46
func (x *StructEntry) GetDefaultVal() string
func (*StructEntry) GetHelpText ¶ added in v0.0.46
func (x *StructEntry) GetHelpText() string
func (*StructEntry) GetMatchText ¶ added in v0.0.46
func (x *StructEntry) GetMatchText() string
func (*StructEntry) GetStructName ¶ added in v0.0.46
func (x *StructEntry) GetStructName() string
func (*StructEntry) GetStructType ¶ added in v0.0.46
func (x *StructEntry) GetStructType() string
func (*StructEntry) ProtoMessage ¶ added in v0.0.46
func (*StructEntry) ProtoMessage()
func (*StructEntry) ProtoReflect ¶ added in v0.0.46
func (x *StructEntry) ProtoReflect() protoreflect.Message
func (*StructEntry) Reset ¶ added in v0.0.46
func (x *StructEntry) Reset()
func (*StructEntry) String ¶ added in v0.0.46
func (x *StructEntry) String() string
type StructEntryScanner ¶ added in v0.0.46
func (*StructEntryScanner) Next ¶ added in v0.0.46
func (it *StructEntryScanner) Next() *StructEntry
Next() returns the next thing in the array
func (*StructEntryScanner) Scan ¶ added in v0.0.46
func (it *StructEntryScanner) Scan() bool
Source Files
¶
- argv.marshal.pb.go
- argv.match.go
- argv.parseOsArgs.go
- argv.pb.go
- argv.print.go
- argv.sort.pb.go
- argv.version.go
- defer_after.go
- errors.go
- exit.go
- fakeStdout.go
- generate.go
- gui.go
- init.go
- makeAutocompleteFiles.bash.go
- makeAutocompleteFiles.go
- makeAutocompleteFiles.zsh.go
- notsure.go
- structs.go
- theMagicOfAutocomplete.go
- verifyApplication.go