Add status command

This commit is contained in:
Mikołaj Pęczkowski 2021-11-05 18:19:06 +01:00
parent 2b4c6d3318
commit e26879425f
9 changed files with 589 additions and 10 deletions

View file

@ -23,6 +23,7 @@ func ParseCliArguments(name, description string, arguments []string) (CliArgumen
parser := argparse.NewParser(name, description)
syncCMD := parser.NewCommand("sync", "Synchronize repositories with remote branches, if the repository does not exist, clone it. (If pulling is not possible, the repository will be fetched)")
statusCMD := parser.NewCommand("status", "Get information about repositories")
configFile := parser.String("c", "config-file", &argparse.Options{
Default: getDefaultConfigDir(),
@ -38,16 +39,19 @@ func ParseCliArguments(name, description string, arguments []string) (CliArgumen
Default: false,
Help: "Turn off color printing",
})
if err := parser.Parse(arguments); err != nil {
return CliArguments{}, err
return CliArguments{}, errors.New(parser.Usage("Please follow this help"))
}
if !syncCMD.Happened() && !(*version) {
if !syncCMD.Happened() && !(*version) && !statusCMD.Happened() {
return CliArguments{}, errors.New(errNoCommand)
}
return CliArguments{
ConfigurationFile: *configFile,
Sync: syncCMD.Happened(),
Status: statusCMD.Happened(),
Version: *version,
Color: !(*color),
}, nil