-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Teletype subcommand creation causes nil reference error #46
Comments
Yep, contacts already existed. Created with add command earlier. |
What might not be clear is - are we permitted to add a sub command to an existing command? It does not appear this is supported: teletype add main
teletype add main sub I made a small script to show the issue: #!/bin/bash
VER=2.5.1
rm -rf works || true
rm -rf issue || true
echo $VER > .ruby-version
echo "**** NEW PROJECT works ****"
teletype new works
cd works
echo $VER > .ruby-version
echo "**** ADD main sub ****"
teletype add main sub
cd ..
echo "**** NEW PROJECT issue ****"
teletype new issue
cd issue
echo $VER > .ruby-version
echo "**** ADD main ****"
teletype add main
echo "**** ADD sub ****"
teletype add main sub I using the latest tty gem this is what I see for output:
|
This is not supported. Why is that? It is impossible to distinguish between command argument and subcommand name. To make it more concrete: mytool main arg # the arg is the argument to command main
mytool main subcmd # the subcmd is a sub command name How would
This will genearte a command def main(arg1)
if arg1 == 'subcmd'
# invoke subcmd
end
end The On the other hand if you wish tty add main subcmd1
tty add main subcmd2
... Then you can run: mytool main # lists all subcommands
mytool main subcmd1
mytool main subcmd2 Does that make sense? It probably would be beneficial to provide automatic explanation for this when generating commands or improve documentation? |
As I get to know the toolkit better I see what you mean. It might be helpful in section 2.8 to specifically address this point. The way it flows is here's how to do a command called "config" and how it can do a few things, then let's (also) add a subcommand called "config set". If you would like I could make a PR with some documentation edits that might help the new user. (because I am one right now so I know what's got me puzzled here and there). I think that there's a case that could be made for section 2.9 which would be the kitchen sink example. In fact It think I'll build one now for myself and would be happy to add to the above edit. I would recommend that if a command is detected when adding a subcommand that it fail and advise the user as such. |
I view documentation as essential to tty adoption. So I'm always happy to receive PRs improving the docs! If you can chunk your changes into smaller PRs that will be even better so I can review them quicker and merge. Thanks! I will have to see what is the best approach in handling the subcommand generation when the command is already present, whether an error message gets displayed or the |
I cannot use teletype to create a subcommand of a command.
When I do I get an exception
It doesn't matter if I try to define parameters or not. I met this problem when I tried a more complex call:
Ultimately resulted in the same exception, from the same place
The text was updated successfully, but these errors were encountered: