diff --git a/main.go b/main.go index cdc9df2..cc5b798 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "github.com/NBISweden/sda-cli/decrypt" "github.com/NBISweden/sda-cli/download" "github.com/NBISweden/sda-cli/encrypt" - "github.com/NBISweden/sda-cli/helpers" "github.com/NBISweden/sda-cli/htsget" "github.com/NBISweden/sda-cli/list" "github.com/NBISweden/sda-cli/login" @@ -20,10 +19,29 @@ import ( var Version = "0-development" -var Usage = `USAGE: %s -config [command-args] +var Usage = `Usage: sda-cli [-config CONFIGFILE] [options] -This is a helper tool that can help with common tasks when interacting -with the Sensitive Data Archive (SDA). +A tool for common tasks with the Sensitive Data Archive (SDA) + +Commands: + createKey Creates a Crypt4GH key pair + decrypt Decrypt files + download Download files from SDA + encrypt Encrypt files + htsget Get files using htsget + list List files in the SDA + login Login to the SDA + upload Upload files to the SDA + +Global options: + -config CONFIGFILE Path to the configuration file + +Additional commands: + version Show the version of the tool + help Show this help message + -h, -help Show this help message + +Run 'sda-cli help ' for more information on a command. ` // Map of the sub-commands, and their arguments and usage text strings @@ -80,9 +98,11 @@ func main() { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } + + os.Exit(0) } -// Parses the command line arguments into a command, and keep the rest +// Parse the command line arguments into a command, and keep the rest // of the arguments for the subcommand. func ParseArgs() (string, []string, string) { var configPath string @@ -152,7 +172,7 @@ func ParseArgs() (string, []string, string) { return command, os.Args, configPath } -// Prints the main usage string, and the global help or command help +// Print the main usage string, and the global help or command help // depending on the command argument. Returns an error if the command // is not recognized. func Help(command string) error { @@ -163,15 +183,7 @@ func Help(command string) error { } // print main help - fmt.Fprintf(os.Stderr, Usage, os.Args[0]) - fmt.Fprintln(os.Stderr, "The tool can help with these actions:") - for _, info := range Commands { - subcommandUsage := helpers.FormatSubcommandUsage(info.usage) - fmt.Fprint(os.Stderr, subcommandUsage) - } - fmt.Fprintf(os.Stderr, - "use '%s help ' to get help with subcommand flags.\n", - os.Args[0]) + fmt.Println(Usage) if command == "help" { return nil @@ -180,7 +192,7 @@ func Help(command string) error { return fmt.Errorf("unknown command: %s", command) } - // print subcommand help + // Print subcommand help fmt.Fprintf(os.Stderr, info.usage+"\n", os.Args[0]) fmt.Fprintln(os.Stderr, "Command line arguments:") info.args.PrintDefaults()