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

[development] click CLI + some styling in responses #2

Merged
merged 7 commits into from
Feb 20, 2020

Conversation

leonkozlowski
Copy link
Contributor

@leonkozlowski leonkozlowski commented Feb 18, 2020

jpl
NEW
-Added a CLI built with Click
-Moved some logic over to jpl/cli/main_cli.py for generating JiggyPlaybookLint response

USAGE

$ jpl --help

Usage: jpl [OPTIONS]

  Click CLI entrypoint to run JiggyPlaybookLint.

  CLI Args: 
-v --verbose: Run `jpl` with verbosity. 
-s --skip: Skip "PASSED" rules in JiggyPlaybookLint Report.
-p --playbook: Location of JiggyPlaybook to lint.

  Args:     verbose: (count) - flag to denote response with verbosity
  skip: (str) - Skip "PASSED" rules in JiggyPlaybookLint Report.
  playbook: (str) - Location of JiggyPlaybook to lint.

  Returns:     click.echo - `with style`

Options:
  -v, --verbose        Run `jpl` with verbosity.
  -s, --skip TEXT      Skip `PASSED` rules in jpl report
  -p, --playbook TEXT  Filepath to Jiggy Playbook  [required]
  --help               Show this message and exit.

On a file

$ jpl -vv -p examples/jiggy-playbook-flawed.yml

   __        ______      __
  /\ \      /\  == \    /\ \
 _\_\ \     \ \  _-/    \ \ \____
/\_____\     \ \_\       \ \_____\
\/_____/iggy  \/_/laybook \/_____/inter

[I03] PlaybookHasDescription:                     WARNING     Playbook `description` has not been declared.
[P02] RunnerIsSupported:                          FAILED      Declared Runner: `something else` is not supported.
[P03] SecretsHasMetadata:                         FAILED      Secrets requires attribute `source`.
[F01] FunctionSourceExists - print-somethin:      FAILED      Declared path to function: `examples.utils.string_manipulation.PrintThis` does not exist.
[F02] ParamHasType - print-somethin:              FAILED      Function: `PrintThis` missing required argument `type`.
[F01] FunctionSourceExists:                       FAILED      Declared path to function: `examples.utils.string_manipulation.PrintThis` does not exist.
[T01] TaskHasName:                                FAILED      Task `name` has not been declared.
[F01] FunctionSourceExists - print-somethin-3:    FAILED      Declared path to function: `examples.utils.string_manipulation.PrintThis` does not exist.
[T02] TaskHasDescription - print-somethin-3:      WARNING     Task `description` has not been declared.
[F01] FunctionSourceExists - get-current-date:    FAILED      Declared path to function: `examples.utils.dates.GetDateTask` does not exist.
[F01] FunctionSourceExists - get-first-letter:    FAILED      Declared path to function: `examples.utils.dates.GetFirstLetter` does not exist.
[T02] TaskHasDescription - get-first-letter:      WARNING     Task `description` has not been declared.
[F01] FunctionSourceExists - get-weekday:         FAILED      Function: `None` missing attribute `source`.
[T03] TaskHasFunction - get-weekday:              FAILED      Task `function` has not been declared.

EDIT
-Made change for -s to be -is_flag
-Added further docstrings + type annotating
-Added README.md

Copy link

@mitchbregs mitchbregs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, looks f'n awesome

required=False,
default="true",
help="Skip `PASSED` rules in jpl report",
)
Copy link

@mitchbregs mitchbregs Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@click.option('--verbose', '-v', is_flag=True, help="Print more output.")

I think this is the closest thing to store_true in argparse. Might be a bit better than "true" as a string.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@click.option('--skip', '-s', is_flag=True, help="Skip PASSED rules in jpl report.")

Copy link
Contributor Author

@leonkozlowski leonkozlowski Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_flag will work here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For —verbose We will want a count so we can increase verbosity

@leonkozlowski
Copy link
Contributor Author

@mitchbregs I made the is_flag change you requested - other changes are docs #3 and added README.md

Copy link

@mitchbregs mitchbregs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome

@leonkozlowski leonkozlowski merged commit 272697a into development Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants