Skip to content

Commit 7e94307

Browse files
committed
Fill in some default values directly if provided by the rules file
1 parent e6526b2 commit 7e94307

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

example/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"root": ".",
2+
"root": "$HOME/dots",
33
"vars_file": ".config/ix/ixrc",
44
"parse": [
55
{

ix.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,6 @@ def main(rules = None):
957957
parser.add_argument('-v', '--verbose', help='Output extra information about what is happening', action='store_true')
958958

959959
args = parser.parse_args()
960-
961960
json_rules = None
962961

963962
if args.rules:
@@ -968,7 +967,10 @@ def main(rules = None):
968967
verbose = True;
969968

970969
if args.config:
971-
config_path = args.config
970+
if args.rules:
971+
config_path = json_rules['vars_file']
972+
else:
973+
config_path = args.config
972974

973975
if args.field:
974976
config = read_config(config_path)
@@ -980,7 +982,10 @@ def main(rules = None):
980982
exit()
981983

982984
if args.directory:
983-
root_path = pathlib.Path(args.directory).absolute()
985+
if args.rules:
986+
root_path = pathlib.Path(os.path.expandvars(json_rules['root'])).absolute()
987+
else:
988+
root_path = pathlib.Path(os.path.expandvars(args.directory)).absolute()
984989

985990
# Load in the cache if not specified
986991
# otherwise.

0 commit comments

Comments
 (0)