fnm icon indicating copy to clipboard operation
fnm copied to clipboard

Added json option to env command

Open zaucy opened this issue 2 years ago • 5 comments

Main motivation for this PR is to make the nushell experience better (#463). Taken from one of the suggestions in the comments I added a --json option.

fnm env --json | from json | load-env
let-env PATH = ($env.PATH | prepend ($env.FNM_MULTISHELL_PATH + "/bin"))

zaucy avatar Aug 17 '22 06:08 zaucy

🦋 Changeset detected

Latest commit: 456093fbff6525d75037c478151d057fe4409427

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
fnm Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Aug 17 '22 06:08 changeset-bot[bot]

ah and by the way, thanks for stepping up and making a PR. I really appreciate your contribution. It's not something I take for granted :pray:

Schniz avatar Aug 17 '22 06:08 Schniz

Thanks for the review and improvement suggestions! I'll be honest my decision making was mainly driven by my lack of experience with rust haha.

I 100% agree adding nushell to the --shell option would be much better. I initially went down that route, but got a little stuck with functions such as to_clap_shell since nushell wasn't part of the result enum. I figured the json way was less intrusive in the codebase as a first step considering my lack of rust experience.

zaucy avatar Aug 17 '22 06:08 zaucy

re: to_clap_shell:

  • it's currently not returning Option<Shell> but I think we should do that, in the meantime we can panic like we do in WinCmd: https://github.com/Schniz/fnm/blob/c85ff97f1404b0042f7378acb0ad67b3fd607189/src/shell/windows_cmd/mod.rs#L8-L11
  • we can also link to this issue: https://github.com/clap-rs/clap/issues/2778

(off topic, I'm using lists on github any time I want to link to an issue just to have the nice formatting they do on lists. FORMATTING ISSUES EVERYWHERE IN GITHUB WEN)

Schniz avatar Aug 17 '22 07:08 Schniz

my decision making was mainly driven by my lack of experience with rust

I built fnm in Rust when I had zero experience in Rust, I want to refactor so much of the current code but I have no time 😜 you're doing good :pray:

Schniz avatar Aug 17 '22 07:08 Schniz

@zaucy I took the liberty to fix conflicts so I'll merge this finally. Sorry it took so long. :pray_parrot:

Schniz avatar Nov 16 '22 18:11 Schniz

Ayy! Love that

zaucy avatar Nov 16 '22 19:11 zaucy