Skip to content

Commit

Permalink
Show command & description when running
Browse files Browse the repository at this point in the history
  • Loading branch information
lennardv2 committed Jan 12, 2021
1 parent 92be59f commit f62e5be
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ehh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# pip install colorama click

import sys

try:
import click
import colorama
Expand All @@ -16,7 +17,7 @@
import re

__author__ = "Lennard Voogdt"
__version__ = "1.0.0"
__version__ = "1.0.1"

commands = []
commandsJsonFile = os.environ['HOME'] + '/ehh.json'
Expand Down Expand Up @@ -62,7 +63,7 @@ def echoCommand(command, index):
def echoCommandBig(command, index):
click.echo("Id: " + str(index))
click.echo("Command: " + Fore.MAGENTA + command['command'] + Fore.RESET)
click.echo("Description: " + command['description'])
click.echo("Description: " + Fore.LIGHTBLUE_EX + command['description'] + Fore.RESET)
click.echo("Group: " + command['group'])
click.echo("Alias: " + command['alias'])

Expand All @@ -74,7 +75,13 @@ def echoGroup(group):

click.echo(" ")

def execCommand(command):
def execCommand(match):
command = match['command']

click.echo("Running: " + Fore.MAGENTA + command + Fore.RESET)
click.echo("Description: " + Fore.LIGHTBLUE_EX + match['description'] + Fore.RESET)
click.echo("")

commandVars = re.findall(r"\(:(.+?)\)",command)
# Remove dups
commandVars = list(dict.fromkeys(commandVars))
Expand All @@ -83,8 +90,6 @@ def execCommand(command):
answer = click.prompt(var)
command = command.replace("(:" + var + ")", answer)

click.echo("Running: " + Fore.MAGENTA + command + Fore.RESET)

os.system(command)

@main.command()
Expand Down Expand Up @@ -134,7 +139,7 @@ def run(query, confirmation):
answer = click.confirm('Run ' + Fore.MAGENTA + match['command'] + Fore.RESET, default=True)

if (confirmation == False or answer):
execCommand(match['command'])
execCommand(match)
break

@main.command()
Expand Down

0 comments on commit f62e5be

Please sign in to comment.