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

Support Bash Arrays #182

Open
wahrwolf opened this issue Jul 19, 2019 · 1 comment
Open

Support Bash Arrays #182

wahrwolf opened this issue Jul 19, 2019 · 1 comment

Comments

@wahrwolf
Copy link

wahrwolf commented Jul 19, 2019

Hi there,
I love fire but I keep running in the same issue.

A lot of my scripts support a target directive so I can handover a list and it will iterate over the list.

If I combine that with Fire I need to write ugly python lists and can not use bash magic.
E.g. I need to write python example.py count_lines '["file00", "file01", "file02"...]' instead of something like 'python example.py count_lines "file{00..10}"` and I can not use any tab completion.

My current workaround is adding:

def count_lines(files):
  if isinstance(files, str):
    files = files.split()
  ...

One idea was to add this line with a special param like --use-bash-arrays to the Fire parser so I can run the script like: python example.py count_lines "ffiles{00..}" -- --use-bash-arrays

@siddharths2710
Copy link

Hello @dbieber and @wahrwolf ,
I would like to contribute to this enhancement, and to this end, I'd like to discuss how to resolve this issue.
With the --use-bash-arrays parameter proposed by @wahrwolf , I have the following questions:

  • How can we infer the element type in the bash array? One solution that comes to mind is through another parameter which serves the purpose, ex. --bash-array-elem-type=str
  • Introducing a new command line parameter would mean to handle a similar named function argument in the Python code. For instance, ( although unlikely ) , the count_lines function may define a use-bash-arrays variable as a parameter in its signature. Any mechanism of handling this occurrence?
  • A Bash array may also be specified like ( f1 f2 f3 ... ) . Should we accommodate such a declaration as well?

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

Successfully merging a pull request may close this issue.

3 participants