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

How to behave like ls? #81

Closed
samhocevar opened this issue Jun 10, 2020 · 3 comments
Closed

How to behave like ls? #81

samhocevar opened this issue Jun 10, 2020 · 3 comments

Comments

@samhocevar
Copy link

The GNU ls utility allows its flags to be provided anywhere in the commandline, e.g.:

ls -l file1 file2 file3
ls file1 file2 file3 -l

If I understand correctly, .remaining(); does not allow that. Is there a workaround for this or another way to do it?

@p-ranav
Copy link
Owner

p-ranav commented Jun 10, 2020

If you know the number of "file" arguments, then you can use specify nargs and place the optional argument -l where ever in the list.

But if you need remaining, at the moment this is not possible. See here.

NOTE: Remember to place all optional arguments BEFORE the remaining argument. If the optional argument is placed after the remaining arguments, it too will be deemed remaining:

$ ./compiler foo.cpp bar.cpp baz.cpp -o main
5 arguments provided
foo.cpp
bar.cpp
baz.cpp
-o
main

I'll keep this issue open as it is worth looking into this to see if it is feasible in the current implementation.

@hokacci hokacci mentioned this issue Sep 10, 2021
@p-ranav
Copy link
Owner

p-ranav commented Jun 22, 2022

@samhocevar There's a new release of argparse that will support this feature request. Hope this helps.

Regards,

@p-ranav p-ranav closed this as completed Jun 22, 2022
@samhocevar
Copy link
Author

Thanks for taking the time to let me know. I ended up not using argparse but it seemed pretty clean at the time, so I think I will evaluate it again.

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

No branches or pull requests

2 participants