diff options
Diffstat (limited to 'interface.go')
| -rw-r--r-- | interface.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/interface.go b/interface.go new file mode 100644 index 0000000..d6d4a63 --- /dev/null +++ b/interface.go @@ -0,0 +1,66 @@ +package prep + +// this is a work in progress + +// Versioned is the interface that the destination struct should implement to +// make a version string appear at the top of the help message. +type Appnamed interface { + // Version returns the version string that will be printed on a line by itself + // at the top of the help message. + Appname() string +} + +type AutoFuncd interface { + // Version returns the version string that will be printed on a line by itself + // at the top of the help message. + DoAutoComplete(*Auto) +} + +type Buildtimed interface { + Buildtime() (string, string) +} + +type Examplesd interface { + // Version returns the version string that will be printed on a line by itself + // at the top of the help message. + Examples() string +} + +type ExitI interface { + // Version returns the version string that will be printed on a line by itself + // at the top of the help message. + Exit() +} + +// Described is the interface that the destination struct should implement to +func findAppInfo(tmp interface{}) { + if tmp, ok := tmp.(Appnamed); ok { + myAuto.appName = tmp.Appname() + } else { + panic("you must define in your app the function: (argv) func Appname() string") + } + + if tmp, ok := tmp.(Buildtimed); ok { + myAuto.buildtime = tmp.Buildtime + } else { + // panic("you need to make the function argv.Appname()") + } + + if tmp, ok := tmp.(Examplesd); ok { + myAuto.examples = tmp.Examples + } else { + // panic("you need to make the function argv.Appname()") + } + + if tmp, ok := tmp.(AutoFuncd); ok { + myAuto.autoFunc = tmp.DoAutoComplete + } else { + // panic("you need to make the function argv.DoAutoComplete()") + } + + if tmp, ok := tmp.(ExitI); ok { + myAuto.appExit = tmp.Exit + } else { + // panic("you need to make the function argv.Exit()") + } +} |
