From 888843cae7b02161f66396be2e82991e062e1e9b Mon Sep 17 00:00:00 2001 From: Elkin Aguas Date: Thu, 25 Jan 2024 22:25:34 +0000 Subject: [PATCH] Add support to create multiple files for clir config --- clir/cli.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/clir/cli.py b/clir/cli.py index ae5c703..4e06db6 100644 --- a/clir/cli.py +++ b/clir/cli.py @@ -22,17 +22,19 @@ def init(): os.makedirs(dir_path, exist_ok=True) # Define the file path and name - file_path = os.path.join(dir_path, 'commands.json') + files = ['commands.json', 'credentials.json'] # Check if the file already exists - if not os.path.exists(file_path): - # Create the file - with open(file_path, 'w') as file: - file.write('{}') + for file in files: + file_path = os.path.join(dir_path, file) + if not os.path.exists(file_path): + # Create the file + with open(file_path, 'w') as file_object: + file_object.write('{}') - print(f'File "{file_path}" created successfully.') - else: - print(f'A clir environment already exists in "{dir_path}".') + print(f'File "{file_path}" created successfully.') + else: + print(f'A clir environment already exists in "{dir_path}".') @cli.command(help="Save new command 💾") @click.option('-c', '--command', help="Command to be saved", prompt=True) @@ -83,4 +85,10 @@ def cp(tag: str = "", grep: str = ""): @click.option('-g', '--grep', help="Search by grep") def tags(grep: str = ""): table = CommandTable(grep=grep) - table.show_tags() \ No newline at end of file + table.show_tags() + +@cli.command(help="Back up commands 🗄") +@click.option('-n', '--now', is_flag=True, help="Backup commands right away") +def backup(now): + if now: + print("Do backup now") \ No newline at end of file