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

z init doesn't work #70

Closed
euank opened this issue May 24, 2018 · 2 comments · Fixed by #72
Closed

z init doesn't work #70

euank opened this issue May 24, 2018 · 2 comments · Fixed by #72
Milestone

Comments

@euank
Copy link
Owner

euank commented May 24, 2018

This issue is suspiciously like #60, but instead of things that autosuggest to something, it's jumps that exactly match something.

This can also be seen in typing pazi --dir init which should look for directories containing init, but instead prints out help output.

@euank euank added this to the v0.0.3 milestone Jun 7, 2018
@euank
Copy link
Owner Author

euank commented Jun 7, 2018

Unfortunately it seems like there's no way to fix this with the cli structure as it is.

The combination of features interacting are the following:

  1. Subcommands (pazi edit)
  2. A flag + optional flag (pazi --dir and pazi --dir foo -i)
  3. The flags not being well ordered with arguments they may take (e.g. z -i foo is pazi --dir -i foo and z foo -i is pazi --dir foo -i and both should work)

I can't find any way to make the above work unfortunately. To have both pazi --dir -i foo and pazi -i --dir foo work, I end up needing to make foo a "trailing" argument instead of a value of "--dir". If it's a value, then z -i foo no longer works.

If it's a trailing argument, clap can't distinguish it from a subcommand, so I need a way to do either of the following:

  1. Make --dir being present imply that no subcommands will be parsed
  2. Make -i or any other -flag not bind to --dir's argument, and then make the target a value of --dir (that is, make pazi --dir -i foo be treated as if foo is a value of --dir)

I'll do one more look through the docs to see if 1. is possible. After laying it out like this in text vs bumbling about with trial and error, it seems worth giving it another look...

If the above all still seems hopeless, I think --dir will have to be moved to a subcommand (e.g. _jump or something)

@LinuxMercedes
Copy link
Collaborator

At this point I think the less hacky choice would be to rename pazi --dir to pazi jump; this would also let us make -i a feature of the jump subcommand so that, say, pazi -i init doesn't work.

If you're (reasonably) concerned about backwards compatibility, I think adding jump in addition to --dir and switching pazi init to use pazi jump instead of pazi --dir, then removing --dir later on would fix most of that problem. Alternatively, we could have any use of --dir return with exit code 92 and an error message telling the user to restart their shell.

euank added a commit that referenced this issue Jun 10, 2018
This fixes #70.

Prior to this change, there was a mix of subcommands and flags that were
all mutually-exclusive behaviors.
This ended up being a bit awkward and made some configurations
ambiguous.

This moves to a much nicer structure. There are global flags (right now
just debug), and then there are subcommands for each distinct
mode of operation.

For ease of migration, the previous logic still remains, but it can be
safely deleted after another release or so to allow migration.
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 a pull request may close this issue.

2 participants