go-arg icon indicating copy to clipboard operation
go-arg copied to clipboard

Accept only argument as environment variable

Open padilo opened this issue 3 years ago • 4 comments

Now ignores if the short argument is empty, so we can only accept the environment variable.

I notice that test: TestInvalidShortFlag breaks, but it seems this test was done thinking that it shouldn't support a short flag with more than one character. Thinks like this one: -foo... Not sure if I can remove this test

Closes #179

padilo avatar May 20 '22 15:05 padilo

https://github.com/alexflint/go-arg/blob/f0f44b65d1179ccedb4c56f493f97ec569a6654e/parse_test.go#L232-L238

padilo avatar May 20 '22 15:05 padilo

Result of this test is:

    	Error Trace:	parse_test.go:237
    	Error:      	An error is expected but got nil.
    	Test:       	TestInvalidShortFlag

Which should be ok, but the name of the test or the idea rear it seems to be incorrect

padilo avatar May 20 '22 15:05 padilo

@padilo thank you for putting this together.

Can you please add some unit tests for the feature you're adding (options that are only settable via environment-variables?). Also please add some tests in usage_test.go so we can see what the usage and help strings look like for arguments that use this feature.

All tests currently pass on master, so I think your change must cause the test breakage in TestInvalidShortFlag

alexflint avatar May 20 '22 16:05 alexflint

I think I understand what that test is supposed to do... @alexflint seems like the environment-only variables were possible. I just tried to include it in the usage + help.

I'm not sure if the format of usage should be this way. I don't like it at all

padilo avatar May 21 '22 15:05 padilo

Hi @padilo

may I take this over to finish it? Or are you still working on it? I would add you and myself as Co-Author.

IljaN avatar May 06 '23 15:05 IljaN

These changes were incorporated into #222, which has now been merged

alexflint avatar Jul 02 '23 14:07 alexflint