Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] [Breaking changes!] Add shorthand flags #171

Merged
merged 7 commits into from
Dec 23, 2016

Conversation

xmudrii
Copy link
Contributor

@xmudrii xmudrii commented Dec 13, 2016

I'm starting this as idea to make shorthand flags work.
Current status when you execute doctl compute droplet delete:

Delete droplet by id or name

Usage:
  doctl compute droplet delete ID [ID|Name ...] [flags]

Aliases:
  delete, d, del, rm


Flags:
      --force   Force droplet delete
  -h, --help    help for delete

Global Flags:
  -t, --access-token string   API V2 Access Token
  -c, --config string         config file (default is $HOME/.config/doctl/config.yaml)
  -o, --output string         output format [text|json] (default "text")
      --trace                 trace api access
  -v, --verbose               verbose output

Error: (droplet.delete) command is missing required arguments

If you want to force delete, you'll have to type --force. I don't see that natural in Unix world, as it's mostly normal to have shorthand flag (-f).

When I was implementing delete confirm in #148, there was no way to do it, and at that point I had no time to play around it.

That's not only for force, it's for all flags.

This is ready code, it's fully usable (I'm not sure about tests tho), and it's working.
I added one more argument for shorthand Add*Flag and changed from * to *P (e.g. String to StringP).

I feel like it could be done better, but let's discuss and give me idea if you agree with adding shorthand flags.

When you execute same command after chagnes:

Delete droplet by id or name

Usage:
  doctl compute droplet delete ID [ID|Name ...] [flags]

Aliases:
  delete, d, del, rm


Flags:
  -f, --force   Force droplet delete
  -h, --help    help for delete

Global Flags:
  -t, --access-token string   API V2 Access Token
  -c, --config string         config file (default is $HOME/.config/doctl/config.yaml)
  -o, --output string         output format [text|json] (default "text")
      --trace                 trace api access
  -v, --verbose               verbose output

Error: (droplet.delete) command is missing required arguments

Both -f and --force are working!

I hope you like idea.

cc @aybabtme @phillbaker @andrewsomething @nanzhong @mchitten

@xmudrii xmudrii changed the title [Idea] [Breaking changes!] Added shorthand flags [Idea] [Breaking changes!] Add shorthand flags Dec 13, 2016
@nanzhong
Copy link
Contributor

Nice, I like it! @aybabtme what do you think?

AddStringFlag(cmdDomainCreate, doctl.ArgIPAddress, "", "IP address", requiredOpt())

AddStringFlag(cmdDomainCreate, doctl.ArgIPAddress, "", "", "IP address", requiredOpt())
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny nitpick, extra whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nanzhong fixed. :D I hope it's correct now. Also fixed indentation for volumes.go at one point.
And yea, commit should be formatting but whatever. :P

Copy link
Contributor

@aybabtme aybabtme left a comment

Choose a reason for hiding this comment

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

lgtm!

package doctl

const (
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why this large block of commented out code?

Copy link
Contributor

Choose a reason for hiding this comment

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

My assumption was some placeholder in case we want to introduce more short flags for other things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nanzhong @aybabtme I left it for placeholder, but I removed it. For now I defined it for force action, but we can add more actions later.

@nanzhong
Copy link
Contributor

Thanks @xmudrii for all your contributions. We realize that we've been a little slow to respond, but hoping to change that in the coming year. :) 🎆

@nanzhong nanzhong merged commit 658f28e into digitalocean:master Dec 23, 2016
@xmudrii xmudrii deleted the flags branch December 23, 2016 17:15
@xmudrii
Copy link
Contributor Author

xmudrii commented Dec 23, 2016

No problem, glad to help. :) And that's not a problem. :)

xmudrii added a commit to xmudrii/doctl that referenced this pull request Dec 23, 2016
fixed imports

added copyright headers

vendoring godo update

changes for digitalocean#171
xmudrii added a commit to xmudrii/doctl that referenced this pull request Dec 23, 2016
fixed imports

added copyright headers

vendoring godo update

changes for digitalocean#171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants