From b6fae5dc959fc53eee17c3e8017b030d238d61c4 Mon Sep 17 00:00:00 2001 From: Boris Mattijssen Date: Wed, 29 Mar 2017 11:52:12 +0200 Subject: [PATCH 1/4] Merge cli options --- command/command.go | 2 +- command/opts.go | 5 +++++ main.go | 13 ++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/command/command.go b/command/command.go index 907fda726..8f6ba6c7d 100644 --- a/command/command.go +++ b/command/command.go @@ -28,7 +28,7 @@ func (c *command) Help() string { } return fmt.Sprintf(` - %s +%s %s`, txt, buf.String()) } diff --git a/command/opts.go b/command/opts.go index a108f71f9..d0a766237 100644 --- a/command/opts.go +++ b/command/opts.go @@ -8,5 +8,10 @@ type OutputOpts struct { //NerdOpts are the options that are applicable to all nerd commands. type NerdOpts struct { + ConfOpts +} + +type ConfOpts struct { + ConfigFile string `long:"config" default:"" default-mask:"" env:"CONFIG" description:"location of config file"` OutputOpts } diff --git a/main.go b/main.go index a2e71572f..1947c3ad1 100644 --- a/main.go +++ b/main.go @@ -18,19 +18,14 @@ var ( commit = "0000000" ) -type ConfOpts struct { - ConfigFile string `long:"config" default:"" default-mask:"" env:"CONFIG" description:"location of config file"` - command.OutputOpts -} - func init() { - opts := new(ConfOpts) - _, err := flags.NewParser(opts, flags.IgnoreUnknown).ParseArgs(os.Args[1:]) + opts := new(command.ConfOpts) + _, err := flags.NewParser(opts, flags.None).ParseArgs(os.Args[1:]) if err == nil { conf.SetLocation(opts.ConfigFile) + nerd.SetupLogging(opts.VerboseOutput, opts.JSONOutput) + nerd.VersionMessage(version) } - nerd.SetupLogging(opts.VerboseOutput, opts.JSONOutput) - nerd.VersionMessage(version) } func main() { From 3e0fd5685fbcc0b37a3b2da5a3dc02c6be96640f Mon Sep 17 00:00:00 2001 From: Boris Mattijssen Date: Wed, 29 Mar 2017 11:53:32 +0200 Subject: [PATCH 2/4] Merge cli options --- command/download.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/download.go b/command/download.go index 79a98d80d..66903cc67 100644 --- a/command/download.go +++ b/command/download.go @@ -33,7 +33,7 @@ func DownloadFactory() func() (cmd cli.Command, err error) { cmd := &Download{ command: &command{ help: "", - synopsis: "fetch the output of a task from cloud storage", + synopsis: "Download a dataset from cloud storage", parser: flags.NewNamedParser("nerd download ", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, From 7714d3b5835f2f14bc772cd66f7d72d59feaf25d Mon Sep 17 00:00:00 2001 From: Boris Mattijssen Date: Wed, 29 Mar 2017 12:02:28 +0200 Subject: [PATCH 3/4] Update synopsis --- command/download.go | 2 +- command/login.go | 2 +- command/logs.go | 4 ++-- command/run.go | 13 +++++++++---- command/status.go | 2 +- command/upload.go | 2 +- command/work.go | 2 +- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/command/download.go b/command/download.go index 66903cc67..08290041f 100644 --- a/command/download.go +++ b/command/download.go @@ -33,7 +33,7 @@ func DownloadFactory() func() (cmd cli.Command, err error) { cmd := &Download{ command: &command{ help: "", - synopsis: "Download a dataset from cloud storage", + synopsis: "Download a dataset from cloud storage.", parser: flags.NewNamedParser("nerd download ", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, diff --git a/command/login.go b/command/login.go index 7a939c5e5..24406292e 100644 --- a/command/login.go +++ b/command/login.go @@ -31,7 +31,7 @@ func LoginFactory() func() (cmd cli.Command, err error) { cmd := &Login{ command: &command{ help: "", - synopsis: "setup an authorized session for the cloud", + synopsis: "Setup an authorized session.", parser: flags.NewNamedParser("nerd login", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, diff --git a/command/logs.go b/command/logs.go index 4280a2458..60099961b 100644 --- a/command/logs.go +++ b/command/logs.go @@ -25,8 +25,8 @@ func LogsFactory() func() (cmd cli.Command, err error) { cmd := &Logs{ command: &command{ help: "", - synopsis: "retrieve up-to-date feedback from a task", - parser: flags.NewNamedParser("nerd logs ", flags.Default), + synopsis: "Retrieve up-to-date feedback from a task.", + parser: flags.NewNamedParser("nerd logs ", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, Writer: os.Stderr, diff --git a/command/run.go b/command/run.go index 94ef2aaa8..3468bb081 100644 --- a/command/run.go +++ b/command/run.go @@ -31,8 +31,8 @@ func RunFactory() func() (cmd cli.Command, err error) { cmd := &Run{ command: &command{ help: "", - synopsis: "create a new compute task for a dataset", - parser: flags.NewNamedParser("nerd run ", flags.Default), + synopsis: "Run a new compute task.\nOptionally you can give a dataset-ID as the second argument. This dataset-ID will be available as the NERD_DATASET_INPUT env variable inside the container.", + parser: flags.NewNamedParser("nerd run [dataset-ID]", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, Writer: os.Stderr, @@ -55,10 +55,15 @@ func RunFactory() func() (cmd cli.Command, err error) { //DoRun is called by run and allows an error to be returned func (cmd *Run) DoRun(args []string) error { - if len(args) < 2 { + if len(args) < 1 { return fmt.Errorf("not enough arguments, see --help") } + dataset := "" + if len(args) == 2 { + dataset = args[1] + } + env := make(map[string]string) for i, e := range cmd.opts.Environment { split := strings.Split(e, "=") @@ -73,7 +78,7 @@ func (cmd *Run) DoRun(args []string) error { HandleError(err, cmd.opts.VerboseOutput) } - task, err := client.CreateTask(args[0], args[1], env) + task, err := client.CreateTask(args[0], dataset, env) if err != nil { HandleError(err, cmd.opts.VerboseOutput) } diff --git a/command/status.go b/command/status.go index 0dcf3db08..98e357912 100644 --- a/command/status.go +++ b/command/status.go @@ -28,7 +28,7 @@ func StatusFactory() func() (cmd cli.Command, err error) { cmd := &Status{ command: &command{ help: "", - synopsis: "show the status of all queued tasks", + synopsis: "Show the status of all tasks.", parser: flags.NewNamedParser("nerd status", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, diff --git a/command/upload.go b/command/upload.go index ebcf75202..8765dc1f3 100644 --- a/command/upload.go +++ b/command/upload.go @@ -38,7 +38,7 @@ func UploadFactory() func() (cmd cli.Command, err error) { cmd := &Upload{ command: &command{ help: "", - synopsis: "push task data as input to cloud storage", + synopsis: "Upload a dataset to the cloud storage.", parser: flags.NewNamedParser("nerd upload ", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, diff --git a/command/work.go b/command/work.go index a9ef66fdf..e0eb814eb 100644 --- a/command/work.go +++ b/command/work.go @@ -51,7 +51,7 @@ func WorkFactory() func() (cmd cli.Command, err error) { cmd := &Work{ command: &command{ help: "", - synopsis: "start handling tasks on local compute resources", + synopsis: "Start handling tasks on local compute resources.", parser: flags.NewNamedParser("nerd work", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, From 3153aec6f571e4078b4237a176aa050580651b3c Mon Sep 17 00:00:00 2001 From: Boris Mattijssen Date: Wed, 29 Mar 2017 12:08:33 +0200 Subject: [PATCH 4/4] Add chunked upload synopsis --- command/upload.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command/upload.go b/command/upload.go index 8765dc1f3..c0ed3c5cd 100644 --- a/command/upload.go +++ b/command/upload.go @@ -38,8 +38,8 @@ func UploadFactory() func() (cmd cli.Command, err error) { cmd := &Upload{ command: &command{ help: "", - synopsis: "Upload a dataset to the cloud storage.", - parser: flags.NewNamedParser("nerd upload ", flags.Default), + synopsis: "Upload a dataset to cloud storage.\nOptionally you can specify a dataset-ID to append files to that dataset. This is also useful to continue an upload in case a previous try failed.", + parser: flags.NewNamedParser("nerd upload [dataset-ID]", flags.Default), ui: &cli.BasicUi{ Reader: os.Stdin, Writer: os.Stderr,