Skip to content

Commit

Permalink
Merge pull request #5 from croketillo/croketillo
Browse files Browse the repository at this point in the history
checks in 'clir new'
  • Loading branch information
elkinaguas authored Nov 15, 2023
2 parents 265a8d6 + b0f69a9 commit 79f2cca
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions clir/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import rich_click as click
import os
import subprocess
from rich.prompt import Prompt
from clir.utils.objects import Command
from clir.utils.objects import CommandTable
Expand All @@ -8,6 +9,11 @@
def cli():
pass

def check_config():
dir_path = os.path.join(os.path.expanduser('~'), '.clir')
file_path = os.path.join(dir_path, 'commands.json')

return os.path.exists(file_path)
#--------------------------------------- CLI commands -------------------------------------------------------

@cli.command(help="Clir initial configuration 🛠️")
Expand All @@ -30,6 +36,14 @@ def init():

@cli.command(help="Save new command 💾")
def new():
if not check_config():
print("Initial configuration is not set. Executing 'clir init'...")
subprocess.run(["clir", "init"])

# Check again after executing 'clir init'
if not check_config():
print("Could not set the initial configuration. Unable to add the new command.")
return
command = Prompt.ask("Command")
description = Prompt.ask("Description")
tag = Prompt.ask("Tag")
Expand Down

0 comments on commit 79f2cca

Please sign in to comment.