Comments (12)
Software is opinionated, namsral/flag
is no exception.
from flag.
Could you post your code because in my tests your described scenario works.
from flag.
Ok, I inaccurately described the issue:
Main package imports "github.com/namsral/flag" and calls flag.Parse()
Main package imports a third-party "someotherpackage".
someotherpackage package imports just standard "flag" and declares some flags.
github.com/namsral/flag.Parse() would not see flags, declared through standard flag package in someotherpackage.
That's definitely a shortcoming as you don't have control over third-parties.
from flag.
The flag package is meant to be used by program developers, not library developers. Third party packages should not depend on the flag package. Package variables should be set via exported variables, functions, the init function, etc.
from flag.
there is no limitation on where the flag package should be used from.
from flag.
I beg to differ; as a program developer I would like to have the final say in building the user interface instead of the library developer.
Can you provide me with example where it would be an advantage to include the flag package in a library.
from flag.
Hello, I’m also facing a similar issue. But I cannot get my head around on why this happens.
Following is what I do:
- I’m using goji's -- goji.Serve()
- I have parameter db-address
When I’m running with namsral/flag - I get the error
flag provided but not defined: -db-address
Usage of ./server:
-bind="::8000": Address to bind on. If this value has a colon, as in ":8000" or
"127.0.0.1:9001", it will be treated as a TCP address. If it
begins with a "/" or a ".", it will be treated as a path to a
UNIX socket. If it begins with the string "fd@", as in "fd@3",
it will be treated as a file descriptor (useful for use with
systemd, for instance). If it begins with the string "einhorn@",
as in "einhorn@0", the corresponding einhorn socket will be
used. If an option is not explicitly passed, the implementation
will automatically select among "einhorn@0" (Einhorn), "fd@3"
(systemd), and ":8000" (fallback) based on its environment.
This error comes from https://github.com/zenazn/goji/blob/master/bind/bind.go
When I use the golang's default flag, then the error is gone.
Any reason why this goes away when I use default flags.
from flag.
Within the goji
package replace the flag
import with github.com/namsral/flag
.
from flag.
Replacing flag
is not trivially doable in every situation. For example, I don't believe I can do it in github.com/golang/glog
without forking that package.
from flag.
@namsral: I want to use glog in my main go program. When I pass -logtostderr=true -v=2
to my main go app, I get a flag provided but not defined: -logtostderr
error message back. I tried to export LOGTOSTDERR=true
with no luck.
from flag.
It's bad practice to parse command line options in a library. Please see a previous comment on a similar issue.
from flag.
from flag.
Related Issues (20)
- `go test -v` stops working HOT 4
- using config file by default HOT 6
- Execution with -h should just print the usage instruction and exit HOT 2
- print error from config file parsing by default HOT 1
- Parse behaviour is wrong when flag contains "-" HOT 1
- lowercase environment variables HOT 1
- prefix for environment variables HOT 6
- Add camel case flag name example to readme
- type alias for Value, Getter etc.
- Is there a way to disable the ConfigFlagname of a FlagSet?
- Release new version
- Support for fixed-size integer types
- Reading individual values from files (eg. docker secrets) HOT 3
- Support for required flag and Default should be optional
- Out of Sync with latest go version - Newer fork available jnovack/flag HOT 2
- Support Multi Value Flags in Config
- Still Maintained?
- Config file parse failure "configuration variable provided but not defined" is not visible to application HOT 2
- Required environment variables is a regression HOT 6
- Running go test with any of the standard flags throws an "flag provided but not defined:" error HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flag.