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

File paths and altsrc #666

Closed
VMitov opened this issue Sep 16, 2017 · 7 comments
Closed

File paths and altsrc #666

VMitov opened this issue Sep 16, 2017 · 7 comments

Comments

@VMitov
Copy link
Contributor

VMitov commented Sep 16, 2017

When having a flag representing file path and using alternative sources if becomes hard to figure out what the file path is relative to.

  • if you're running from the same folder the config file is - cmd current dir is the same as the config file dir, so it doesn't matter
  • if you're running from different folder and taking the option from the file - path should be treated as relative to the config file
  • if you're running from different folder and taking the option from the cmd - path should be treated as relative to the folder you're running the cmd from

I'm using v2 btw.

@jszwedko
Copy link
Contributor

👍 I agree with these three assertions, can you qualify which are not currently met?

@VMitov
Copy link
Contributor Author

VMitov commented Sep 18, 2017

It depends on the implementation. In my case the last one is failing. If there is a way to find out what is the source of a flag - I would easily fix it.

@VMitov
Copy link
Contributor Author

VMitov commented Sep 20, 2017

I solved it with custom PathFlag. Do you fancy PR? The only caveat is - how I know the directory where the config file is in the PathFlag ApplyInputSourceValue?

@jszwedko
Copy link
Contributor

You should be able to get the current working directory via os.Getwd. PRs definitely welcome 😄

@VMitov
Copy link
Contributor Author

VMitov commented Sep 26, 2017

What I mean is that in ApplyInputSourceValue don't have the flag name for the configuration file.

@VMitov
Copy link
Contributor Author

VMitov commented Sep 26, 2017

And that's what I mean :) https://github.com/urfave/cli/pull/670/files#diff-b409136834e66f5a239c3d6ca4df876dR255 . How you think it will be best to fix that? Put it in the context may be?

#670

@VMitov VMitov mentioned this issue Sep 26, 2017
@meatballhat meatballhat self-assigned this Feb 25, 2018
@coilysiren
Copy link
Member

Hiya! There's a known issue with the current implementation of the CLI, where altsrc is generally clunky and poorly documented. My current idea is that I'm going to move all of the altsrc functionality into the main package in some way, and that's how all of the "altsrc is weird and different???" issues people are having will get resolved. I'm tracking that work here => #833

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

4 participants