-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the version command to return more details (#71)
Signed-off-by: oluwole fadeyi <[email protected]>
- Loading branch information
Showing
4 changed files
with
91 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package version | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
type ( | ||
// Options is the list of options/flag available to the application, | ||
// plus the clients needed by the application to function. | ||
Options struct { | ||
Verbose bool | ||
} | ||
) | ||
|
||
// New creates a new instance of the application's options | ||
func New() *Options { | ||
return new(Options) | ||
} | ||
|
||
// Prepare assigns the applications flag/options to the cobra cli | ||
func (o *Options) Prepare(cmd *cobra.Command) *Options { | ||
o.addAppFlags(cmd.Flags()) | ||
return o | ||
} | ||
|
||
// Validate validates the flag values given to the application | ||
func (o *Options) Validate() error { | ||
return nil | ||
} | ||
|
||
// Complete initialises the components needed for the application to function given the options, | ||
func (o *Options) Complete() error { | ||
return nil | ||
} | ||
|
||
func (o *Options) addAppFlags(fs *pflag.FlagSet) { | ||
fs.BoolVarP( | ||
&o.Verbose, | ||
"version", | ||
"v", | ||
false, | ||
"Verbose build information", | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters