Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(check): add new command to lume. use -check to check if your command is… #72

Merged
merged 4 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ jobs:
env:
LUME_CONFIG_FILENAME: examples/lume-sample.yml
run: lume -unavailable-command | true
- name: End2end test (check commands)
env:
LUME_CONFIG_FILENAME: examples/lume-sample.yml
run: |
lume -check test
lume -check other:step-1
lume -check other:step-2
lume -check notexistcommand | true
- name: End2end test (call unavailable command `--no-strict` mode)
env:
LUME_CONFIG_FILENAME: examples/lume-sample.yml
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ optional arguments:
-h, --help show this help message and exit
-v, --version show lume version number.
-all, --all-commands run all commands
-check CHECK, --check CHECK
check if lume command is available or not
-clean, --clean clean
-build, --build build
-test, --test test
Expand Down Expand Up @@ -129,6 +131,16 @@ Here is an example of the log output that would have lume using several commands

## Features

#### Check if a command is available

You can check if a command exist use `lume -check <COMMAND-TO-CHECK>`

Example

````console
lume -check test
````

#### OS-specific commands

Define your os-specific command adding new fields on `run` commands with specific os keys (`linux`, `macos`, `macos-arm` and `windows`)
Expand Down
26 changes: 23 additions & 3 deletions lume/src/application/cli/lume.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def get_parser(config):
)

parser.add_argument(
"-v", "--version", action="store_true", help="show lume version number."
"-v",
"-version",
"--version",
action="store_true",
help="show lume version number.",
)
parser.add_argument(
"-all",
Expand All @@ -80,6 +84,9 @@ def get_parser(config):
dest="all_commands",
help="run all commands",
)
parser.add_argument(
"-check", "--check", type=str, help="check if lume command is available or not"
)
for command in config.get_commands():
parser.add_argument(
f"-{command}",
Expand Down Expand Up @@ -135,11 +142,19 @@ def check_command_availability(strict_mode, not_known, parser, config_file) -> R
return isFailure


def check_given_command(given_command: str, config: Config):
if given_command not in config.get_commands():
print(f"lume 🔥 => `{given_command}` is not available command ❌ ")
return 1
else:
print(f"lume 🔥 => `{given_command}` is an available command ✅ ")
return 0


def main():
start = time.time()
header = f" 🔥 lume {__version__} ({get_platform()} -- Python {platform.python_version()}) "
columns = shutil.get_terminal_size().columns
print(header.center(columns - 10, "="))
result = isFailure
exit_code = 1
suffix = "(exit code 1)"
Expand All @@ -166,7 +181,12 @@ def main():

if args.version:
print(f"lume 🔥 => {__version__}")
return
return 0

if args.check:
return check_given_command(args.check, config)

print(header.center(columns - 10, "="))

selected_actions = [
action
Expand Down