mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Only configure org via config file for consistency across search types
- Previously org-files were configurable via cmdline args. Where as none of the other search types are - This is an artifact of how the application grew - It can be removed for better consistency and equal preference given all search types
This commit is contained in:
parent
da118b3fed
commit
38aede68f2
1 changed files with 4 additions and 13 deletions
|
@ -16,8 +16,6 @@ def cli(args=None):
|
||||||
|
|
||||||
# Setup Argument Parser for the Commandline Interface
|
# Setup Argument Parser for the Commandline Interface
|
||||||
parser = argparse.ArgumentParser(description="Expose API for Khoj")
|
parser = argparse.ArgumentParser(description="Expose API for Khoj")
|
||||||
parser.add_argument('--org-files', '-i', nargs='*', help="List of org-mode files to process")
|
|
||||||
parser.add_argument('--org-filter', type=str, default=None, help="Regex filter for org-mode files to process")
|
|
||||||
parser.add_argument('--config-file', '-c', type=pathlib.Path, help="YAML file with user configuration")
|
parser.add_argument('--config-file', '-c', type=pathlib.Path, help="YAML file with user configuration")
|
||||||
parser.add_argument('--regenerate', action='store_true', default=False, help="Regenerate model embeddings from source files. Default: false")
|
parser.add_argument('--regenerate', action='store_true', default=False, help="Regenerate model embeddings from source files. Default: false")
|
||||||
parser.add_argument('--verbose', '-v', action='count', default=0, help="Show verbose conversion logs. Default: 0")
|
parser.add_argument('--verbose', '-v', action='count', default=0, help="Show verbose conversion logs. Default: 0")
|
||||||
|
@ -27,25 +25,18 @@ def cli(args=None):
|
||||||
|
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
if not (args.config_file or args.org_files):
|
if not (args.config_file):
|
||||||
print(f"Require at least 1 of --org-file, --org-filter or --config-file flags to be passed from commandline")
|
print(f"Need --config-file flag to be passed from commandline")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Config Priority: Cmd Args > Config File > Default Config
|
# Config Priority: Config File > Default Config
|
||||||
args.config = default_config
|
args.config = default_config
|
||||||
if args.config_file and resolve_absolute_path(args.config_file).exists():
|
if args.config_file and resolve_absolute_path(args.config_file).exists():
|
||||||
with open(get_absolute_path(args.config_file), 'r', encoding='utf-8') as config_file:
|
with open(get_absolute_path(args.config_file), 'r', encoding='utf-8') as config_file:
|
||||||
config_from_file = yaml.safe_load(config_file)
|
config_from_file = yaml.safe_load(config_file)
|
||||||
args.config = merge_dicts(priority_dict=config_from_file, default_dict=args.config)
|
args.config = merge_dicts(priority_dict=config_from_file, default_dict=args.config)
|
||||||
args.config = FullConfig.parse_obj(args.config)
|
|
||||||
else:
|
|
||||||
args.config = FullConfig.parse_obj(args.config)
|
|
||||||
|
|
||||||
if args.org_files:
|
args.config = FullConfig.parse_obj(args.config)
|
||||||
args.config.content_type.org.input_files = args.org_files
|
|
||||||
|
|
||||||
if args.org_filter:
|
|
||||||
args.config.content_type.org.input_filter = args.org_filter
|
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue