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

awless stop instance ID returns an error message #99

Closed
sdouche opened this issue May 21, 2017 · 6 comments
Closed

awless stop instance ID returns an error message #99

sdouche opened this issue May 21, 2017 · 6 comments

Comments

@sdouche
Copy link

sdouche commented May 21, 2017

Hi,
It common to write the instance ID in the CLI, but awless returns a error message:

Error: error parsing template at line 1 (char 15):
	-> stop instance X

It would be cool to use the ID for starting / stopping / whatever the instance.

@sdouche sdouche changed the title awless stop instance must use instance ID and not return error message awless stop instance ID returns an error message May 21, 2017
@fxaguessy
Copy link
Contributor

This is normal, as you should write awless stop instance id=i-1234 to stop an instance.

However, typing awless stop instance i-1234 or even awless stop i-1234 is a very common mistake and we are going to think if it's better to keep as it is, in order to educate to the template format (that requires, param=value). Or if we also add these shortcuts.

@simcap
Copy link
Contributor

simcap commented May 22, 2017

In the meantime (while we think of a good approach for that - several come to mind), here is something that can help.

Having the following bash functions in one's env (~/.bashrc, ~/.zshrc or distro appropriate).

function startinstance() {
 awless start instance id="$1" -f
}
function stopinstance() {
 awless stop instance id="$1" -f
}
function delinstance() {
 awless delete instance id="$1"
}

... and completion comes for free! The -f will avoid the prompt, as for stopping/starting one might not want to confirm.

So a typical use would be:

$ stopinstance @my-instance-name    # referring instance by name using the alias notation

or 

$ startinstance id-2352p52j452

@sdouche
Copy link
Author

sdouche commented May 22, 2017

This is normal, as you should write awless stop instance id=i-1234 to stop an instance.

Oh, my bad.

However, typing awless stop instance i-1234 or even awless stop i-1234 is a very common mistake and we are going to think if it's better to keep as it is, in order to educate to the template format (that requires, param=value).

I'm ok with that, so maybe add a more valuable error message like:

Error: error parsing template at line 1 (char 15):
	-> stop instance X
See 'awless stop instance -h'
Did you mean this? awless stop instance id=ID

@sdouche
Copy link
Author

sdouche commented May 22, 2017

Ok I know why I typed the wrong command:
awless ssh ID vs awless stop instances id=ID

@fxaguessy
Copy link
Contributor

Ok I know why I typed the wrong command: awless ssh ID vs awless stop instances id=ID

Good point. Thanks for your feedback, we are going to search a better approach for this and at least improve error messages.

@hbbio
Copy link
Contributor

hbbio commented May 22, 2017

Yes, that's my favorite awless typo too!

Building on what you suggest, we can catch both awless stop instance (id) and even awless stop (id) where typeof(id)==instance_type and:

  1. Display the right suggestion: Did you mean awless stop instance id=(id) (y/n)?
  2. Automatically accept 'y' as an answer to perform the action right away without having to copy/paste or type the command again

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

No branches or pull requests

4 participants