mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 05:39:06 +00:00
Make config_file an optional argument. It can be generated on FRE
- Make config_file an optional arg. It defaults to default khoj config dir - Return args.config as None if no config_file explicitly passed by user - Parent can use args.config = None as signal to trigger first run experience
This commit is contained in:
@@ -9,10 +9,11 @@ import yaml
|
||||
from src.utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
from src.utils.rawconfig import FullConfig
|
||||
|
||||
|
||||
def cli(args=None):
|
||||
# Setup Argument Parser for the Commandline Interface
|
||||
parser = argparse.ArgumentParser(description="Start Khoj; A Natural Language Search Engine for your personal Notes, Transactions and Photos")
|
||||
parser.add_argument('config_file', type=pathlib.Path, help="YAML file to configure Khoj")
|
||||
parser.add_argument('--config-file', '-c', default='~/.khoj/khoj.yml', type=pathlib.Path, help="YAML file to configure Khoj")
|
||||
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('--host', type=str, default='127.0.0.1', help="Host address of the server. Default: 127.0.0.1")
|
||||
@@ -22,14 +23,14 @@ def cli(args=None):
|
||||
args = parser.parse_args(args)
|
||||
|
||||
if not resolve_absolute_path(args.config_file).exists():
|
||||
raise ValueError(f"Config file {args.config_file} does not exist")
|
||||
args.config = None
|
||||
else:
|
||||
# Read Config from YML file
|
||||
config_from_file = None
|
||||
with open(get_absolute_path(args.config_file), 'r', encoding='utf-8') as config_file:
|
||||
config_from_file = yaml.safe_load(config_file)
|
||||
|
||||
# Read Config from YML file
|
||||
config_from_file = None
|
||||
with open(get_absolute_path(args.config_file), 'r', encoding='utf-8') as config_file:
|
||||
config_from_file = yaml.safe_load(config_file)
|
||||
|
||||
# Parse, Validate Config in YML file
|
||||
args.config = FullConfig.parse_obj(config_from_file)
|
||||
# Parse, Validate Config in YML file
|
||||
args.config = FullConfig.parse_obj(config_from_file)
|
||||
|
||||
return args
|
||||
Reference in New Issue
Block a user