Skip to content

Commit

Permalink
Merge pull request #80 from eduardomezencio/cli
Browse files Browse the repository at this point in the history
Simple CLI with all Options implemented
  • Loading branch information
Salamek authored Apr 10, 2024
2 parents 03bd391 + bba5d6e commit a3257ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ celerybeat-schedule
# virtualenv
venv/
ENV/
.venv

# Spyder project settings
.spyderproject
Expand All @@ -90,5 +91,7 @@ ENV/

.idea
.DS_Store
.vimrc
*.swp

# Created by .ignore support plugin (hsz.mobi)
25 changes: 25 additions & 0 deletions cron_descriptor/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import argparse

from cron_descriptor import CasingTypeEnum, ExpressionDescriptor, Options

parser = argparse.ArgumentParser(prog='cron_descriptor')
parser.add_argument('expression')
parser.add_argument('-c', '--casing',
choices=[v for v in vars(CasingTypeEnum)
if not v.startswith('_')],
default='Sentence')
parser.add_argument('-v', '--verbose', action='store_true')
parser.add_argument('-W', '--one-indexed-week', action='store_true')
parser.add_argument('-H', '--use-24-hour-time-format', action='store_true')

args = parser.parse_args()

options = Options()
options.casing_type = getattr(CasingTypeEnum, args.casing)
options.verbose = args.verbose
options.day_of_week_start_index_zero = not args.one_indexed_week
options.use_24hour_time_format = args.use_24_hour_time_format

descriptor = ExpressionDescriptor(args.expression, options)

print(str(descriptor))

0 comments on commit a3257ca

Please sign in to comment.