Skip to content

Commit

Permalink
add -v output
Browse files Browse the repository at this point in the history
  • Loading branch information
hoo29 committed Oct 13, 2024
1 parent e47efcf commit 82bd8ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ skip_dirs:
```text
little-timmy -h
usage: little-timmy [-h] [-c CONFIG_FILE] [-d | --dave-mode | --no-dave-mode] [-e | --exit-success | --no-exit-success] [-g | --github-action | --no-github-action] [-j | --json-output | --no-json-output] [-l LOG_LEVEL] [directory]
usage: little-timmy [OPTIONS] [directory]
Process a directory path
Expand All @@ -120,13 +120,15 @@ options:
-c CONFIG_FILE, --config-file CONFIG_FILE
Config file to use. By default it will search all dirs to `/` for .little-timmy
-d, --dave-mode, --no-dave-mode
Make logging work on dave's macbook
Make logging work on dave's macbook.
-e, --exit-success, --no-exit-success
Exit 0 when unused vars are found.
-g, --github-action, --no-github-action
Output results for github actions.
-j, --json-output, --no-json-output
Output results as json to stdout. Disables the stderr logger.
-l LOG_LEVEL, --log-level LOG_LEVEL
set the logging level (default: INFO)
set the logging level (default: INFO).
-v, --version, --no-version
Output the version.
```
12 changes: 10 additions & 2 deletions little_timmy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .config_loader import find_and_load_config
from .var_finder import find_unused_vars

VERSION = "1.1.2"
LOGGER = logging.getLogger("little-timmy")


Expand All @@ -18,15 +19,17 @@ def main():
parser.add_argument(
"-c", "--config-file", type=str, help="Config file to use. By default it will search all dirs to `/` for .little-timmy")
parser.add_argument("-d", "--dave-mode", default=False, action=argparse.BooleanOptionalAction,
help="Make logging work on dave's macbook")
help="Make logging work on dave's macbook.")
parser.add_argument("-e", "--exit-success", default=False, action=argparse.BooleanOptionalAction,
help="Exit 0 when unused vars are found.")
parser.add_argument("-g", "--github-action", default=False, action=argparse.BooleanOptionalAction,
help="Output results for github actions.")
parser.add_argument("-j", "--json-output", default=False, action=argparse.BooleanOptionalAction,
help="Output results as json to stdout. Disables the stderr logger.")
parser.add_argument("-l", "--log-level", default="INFO", type=str,
help="set the logging level (default: INFO)")
help="set the logging level (default: INFO).")
parser.add_argument("-v", "--version", default=False, action=argparse.BooleanOptionalAction,
help="Output the version.")
args = parser.parse_args()

log_level = getattr(logging, args.log_level.upper(), None)
Expand All @@ -40,6 +43,11 @@ def main():
logging.basicConfig(level=log_level, format="%(message)s")
if args.json_output:
LOGGER.disabled = True

if args.version:
LOGGER.info(VERSION)
sys.exit(0)

LOGGER.debug("starting")

if args.directory == ".":
Expand Down

0 comments on commit 82bd8ad

Please sign in to comment.