Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fleetctl: Need return fail if no args given to some subcommand. #1230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wuqixuan
Copy link
Contributor

Some subcommand like destroy/load/start/status/stop/submit/unload,
need to give prompt if no args for them.
Add the same prompt "One unit file must be provided" as the "cat"
subcommand is doing:
[root@localhost fleet-0.10.1]# fleetctl cat
One unit file must be provided

Some subcommand like destroy/load/start/status/stop/submit/unload,
need to give prompt if no args for them.
Add the same prompt "One unit file must be provided" as the "cat"
subcommand is doing:
[root@localhost fleet-0.10.1]# fleetctl cat
One unit file must be provided
@wuqixuan
Copy link
Contributor Author

Before the code, destroy/load/start/status/stop/submit/unload subcommand without any args will give 0 return value. It should return error code, like -1 as "cat" is doing now. That's why to add those codes.

@scole-scea
Copy link

Maybe: "At least one unit file must be specified."

@wuqixuan
Copy link
Contributor Author

Currently, "cat" subcommand give "One unit file must be provided". So other subcommand I gave the same.

@wuqixuan wuqixuan changed the title fleetctl: Add the args check for some subcommand fleetctl: Need return fail if no correct args for some subcommand. May 19, 2015
@wuqixuan wuqixuan changed the title fleetctl: Need return fail if no correct args for some subcommand. fleetctl: Need return fail if no args given to some subcommand. May 19, 2015
@scole-scea
Copy link

Yes, the cat subcommand does say "one". However, the cat subcommand only takes one unit as an argument.

destroy/load/start/status/stop/submit/unload all take one or more units as arguments.

@wuqixuan
Copy link
Contributor Author

So I think we need modify the message of "cat", instead.

@scole-scea
Copy link

Well, cat has a different command-line interface. There's no reason it's error messages shouldn't reflect that difference.

@@ -29,6 +29,10 @@ Destroyed units are impossible to start unless re-submitted.`,
}

func runDestroyUnits(args []string) (exit int) {
if len(args) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files must be provided

@wuqixuan
Copy link
Contributor Author

@bcwaldon, are all commands or just stop need not give error if no args failing ?
If all commands, then "cat" code need remove the check?

func runCatUnit(args []string) (exit int) {
    if len(args) != 1 {
        stderr("One unit file must be provided")
        return 1
    }

Or some need check, some need not check ? 

@mischief
Copy link
Contributor

@wuqixuan please update the messages as @bcwaldon asked and then lgtm.

@wuqixuan
Copy link
Contributor Author

wuqixuan commented Sep 1, 2015

@mischief, actually I don't know what @bcwaldon exact suggestions are.
Which commands are idempotent without checking, while which need to be checked ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants