Skip to content

Commit

Permalink
Add support to create multiple files for clir config
Browse files Browse the repository at this point in the history
  • Loading branch information
elkinaguas committed Jan 25, 2024
1 parent 7a62b85 commit 888843c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions clir/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
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")

0 comments on commit 888843c

Please sign in to comment.