Closed suntong closed 6 years ago
Same test as above,
.../lang/Go/src/sys/CLI$ 027-global-option
root
{"Host":"regexp\\s+test","Port":8080}{"Host":"regexp\\s+test","Port":8080}
[2 15]
cd ../
.../lang/Go/src/sys$ CLI/027-global-option
root
{"Host":"regexp\\s+test","Port":8080}{"Host":"regexp\\s+test","Port":8080}
[2 15]
I.e. problem fixed -- such with-self-config executable can truly be invoked from everywhere now.
It's not a good idea for changing ReadJSONFromFile
method.
It's not a good idea for changing ReadJSONFromFile method.
Ops. OK. Your call, as long as it works as expected.
Just a precaution, os.Args[0]
will be an empty string when the program is invoked from within the path.
That's why I had to do a second fix for the problem, https://github.com/go-easygen/cli/commit/926c6029618c3d3915b7b27629f864d093eb9039#diff-6314e6e9a009f03a2a8537fd10a4526aR108
Please double check. My OS is
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic
os.Args[0] will be an empty string when the program is invoked from within the path
Can you write an exampe program and how to run it?
"github.com/go-easygen/cli"
..../lang/Go/src/sys$ CLI/027-global-option
, as shown above. github.com/mkideal/cli
(or modify your original global-option.go file) and redo above steps again.
cli
has is to define a self-config .json file that allows using the .json file to control the executable file behavior.cli
currently ready such self-config .json file frompwd
, and would fail if it is not:Using https://github.com/suntong/lang/blob/master/lang/Go/src/sys/CLI/027-global-option.go#L21 to showcase the situation:
If we allow such self-config .json files to reside where the executable file is, then such with-self-config executable can truly be invoked from everywhere.