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

Add support for reading command-line options from file(s) #191

Open
jdegoes opened this issue May 25, 2023 · 28 comments · May be fixed by #308
Open

Add support for reading command-line options from file(s) #191

jdegoes opened this issue May 25, 2023 · 28 comments · May be fixed by #308

Comments

@jdegoes
Copy link
Member

jdegoes commented May 25, 2023

The users command-line app has a top-level command, whose name is <name>.

For example, if the user was creating a word count CLI, then their top-level command name might be wc.

ZIO CLI should examine the following locations to check for the existence of .<name> files:

  1. The current working directory.
  2. All parents of the current working directory.
  3. The user's home directory.

So, in the wc example, if run from /c/Users/john directory, then ZIO CLI would look in the following locations for the existence of .wc files:

  1. /c/Users/john
  2. `/c/Users/
  3. /c/
  4. ~ (user home, probably /c/Users/john on Windows)

Then, ZIO CLI should concatenate these options, with user home having the lowest priority, and the current working directory having the highest priority (so, for example, you can override options in higher priority locations).

Then, ZIO CLI should utilize those command-line options when the program is run, and not require those options be specified. However, if any option is specified on the command-line, then it must override even the highest priority setting specified in the settings files.

An example, let's say wc has an option --line-ending. Then in the .wc file, there might exist:

--line-ending=\n

Then this would be the default line ending. The user would not have to specify it on the command-line. But if the user did specify it on the command-line, it would override the one in the file.

This new functionality should be documented in the help docs for the CLI. Moreover, all of the settings that are picked up from any of the files need to be printed out, so the user can understand exactly where they are coming from.

@jdegoes
Copy link
Member Author

jdegoes commented May 25, 2023

/bounty $250

For the full functionality, implemented in a cross-platform setting, with full test suites, and descriptive help docs, and diagnostics.

@algora-pbc
Copy link

algora-pbc bot commented May 25, 2023

💎 $250 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #191 with your implementation plan
  2. Submit work: Create a pull request including /claim #191 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Additional opportunities:

  • 🔴 Livestream on Algora TV while solving this bounty & earn $200 upon merge! Make sure to have your camera and microphone on. Comment /livestream once live

Thank you for contributing to zio/zio-cli!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @walesho May 26, 2023, 9:12:32 AM WIP
🔴 @vidyasankarv Jun 9, 2023, 11:47:14 AM WIP
🔴 @thisisyoussef Aug 19, 2023, 2:04:17 AM WIP
🔴 @shubhi2000 Sep 2, 2023, 4:25:04 AM WIP
🟡 @vivasvan1 Oct 13, 2023, 12:51:11 PM #308
🟢 @Kalin-Rudnicki Jun 4, 2024, 7:02:24 AM #317

@walesho
Copy link

walesho commented May 26, 2023

/attempt #191

@algora-pbc
Copy link

algora-pbc bot commented Jun 2, 2023

@walesho: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@algora-pbc
Copy link

algora-pbc bot commented Jun 9, 2023

The bounty is up for grabs! Everyone is welcome to /attempt #191 🙌

@algora-pbc
Copy link

algora-pbc bot commented Jun 16, 2023

@vidyasankarv: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@algora-pbc
Copy link

algora-pbc bot commented Jun 23, 2023

The bounty is up for grabs! Everyone is welcome to /attempt #191 🙌

@shubhi2000
Copy link

Hi,
Can I work on this?
It seems interesting!

@thisisyoussef
Copy link

thisisyoussef commented Aug 19, 2023

/attempt #191

Options

@algora-pbc
Copy link

algora-pbc bot commented Aug 26, 2023

@thisisyoussef: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@algora-pbc
Copy link

algora-pbc bot commented Sep 2, 2023

The bounty is up for grabs! Everyone is welcome to /attempt #191 🙌

@shubhi2000
Copy link

shubhi2000 commented Sep 2, 2023

/attempt #191

Options

@algora-pbc
Copy link

algora-pbc bot commented Sep 9, 2023

@shubhi2000: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@shubhi2000
Copy link

Hi,
I am still working on this. Taking some time to setup and understand where exactly this feature needs to be integrated in the codebase. Will reach out with any queries I may have.

@algora-pbc
Copy link

algora-pbc bot commented Sep 16, 2023

The bounty is up for grabs! Everyone is welcome to /attempt #191 🙌

@vivasvan1
Copy link

vivasvan1 commented Oct 13, 2023

/attempt #191

Options

@algora-pbc
Copy link

algora-pbc bot commented Oct 20, 2023

@vivasvan1: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@vivasvan1
Copy link

vivasvan1 commented Oct 26, 2023

@jdegoes
I am still working on documentation and "But if the user did specify it on the command-line, it would override the one in the file." functionality.

  • base functionality
  • user specified argument overrides the one from the file
  • test suite
  • help docs and diagnoses

However would love to know if my attempt is in the right direction.

Copy link

algora-pbc bot commented Apr 18, 2024

💡 @vivasvan1 submitted a pull request that claims the bounty. You can visit your bounty board to reward.

@Kalin-Rudnicki
Copy link
Contributor

Kalin-Rudnicki commented Jun 4, 2024

@jdegoes am I able to attempt this?

If so, please clarify the following questions:

  • if command is ab cd ef --arg-1=1 --arg-2=2, are we looking for .ab or .ef?
  • what is the desired behavior for argument overriding?
    ex:
    /home/user/a/.__:
    --arg-1=1
    --arg-2=1
    
    /home/user/a/b/c/.__:
    --arg-2=2
    --arg-3=2
    
    • Option 1:
      Map(
        "arg-2" -> ("/home/user/a/b/c/.__", "2"),
        "arg-3" -> ("/home/user/a/b/c/.__", "2"),
      )
    • Option 2:
      Map(
        "arg-1" -> ("/home/user/a/.__", "1"),
        "arg-2" -> ("/home/user/a/b/c/.__", "2"),
        "arg-3" -> ("/home/user/a/b/c/.__", "2"),
      )
    • Something else entirely??
  • Is it safe to say that args pulled from files should only be passed to UserDefined and not BuiltIn parsing?
  • What is the intention for printing the arg overrides and such? ZIO.logInfo? ZIO.logDebug?

@Kalin-Rudnicki
Copy link
Contributor

Kalin-Rudnicki commented Jun 4, 2024

/attempt #191

Copy link

algora-pbc bot commented Jun 4, 2024

Note

The user @vivasvan1 is already attempting to complete issue #191 and claim the bounty. We recommend checking in on @vivasvan1's progress, and potentially collaborating, before starting a new solution.

@vivasvan1
Copy link

@Kalin-Rudnicki I am almost done with this PR. Only the documentation is remaining as far as i understand. Let me know if you would like to collaborate on it.

@Kalin-Rudnicki
Copy link
Contributor

Kalin-Rudnicki commented Jun 4, 2024

@vivasvan1, respectfully, I'd be trying to get the bounty 😂😜
I would personally do a significant part of this change in a different manner.
Also, per the lastest commentor, and reading the current version of the PR, the current impl doesnt seem do anything to handle

However, if any option is specified on the command-line, then it must override even the highest priority setting specified in the settings files.

Or

Moreover, all of the settings that are picked up from any of the files need to be printed out, so the user can understand exactly where they are coming from.

And also doesnt seem to handle the more complex cases of arg overriding base on hierarchy

@vivasvan1
Copy link

It's okay you can go ahead with a different PR ... although it would have been faster and easier for both by collaboration in my view.
I am open to splitting the bounty as well.
Anyways, good luck.

@vivasvan1
Copy link

@Kalin-Rudnicki regarding the technicals, I believe my PR does handle i have tested for it as well.

However, if any option is specified on the command-line, then it must override even the highest priority setting specified in the settings files.

And

And also doesnt seem to handle the more complex cases of arg overriding base on hierarchy

Only remaining thing is printing the args. Thanks for pointing it out I had forgotten about it. 🙏

@Kalin-Rudnicki
Copy link
Contributor

I will let ya go for it first :)
I saw you mentioned being new to scala/zio, so I left a bunch of nits on the PR for using better practices

Copy link

algora-pbc bot commented Jun 8, 2024

💡 @Kalin-Rudnicki submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Kalin-Rudnicki added a commit to Kalin-Rudnicki/zio-cli that referenced this issue Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants