Skip to content

Commit

Permalink
Fix default boolean options always going to False (runtimeverificatio…
Browse files Browse the repository at this point in the history
…n/pyk#955)

The parsed command line args are always getting False when no `default`
is specified. However I had written code assuming that args would
default to either None or the empty list for list type arguments..

---------

Co-authored-by: devops <[email protected]>
  • Loading branch information
2 people authored and Baltoli committed Apr 9, 2024
1 parent 5e249a1 commit 0a16336
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pyk/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
project = 'pyk'
author = 'Runtime Verification, Inc'
copyright = '2024, Runtime Verification, Inc'
version = '0.1.689'
release = '0.1.689'
version = '0.1.690'
release = '0.1.690'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyk/package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.689
0.1.690
2 changes: 1 addition & 1 deletion pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pyk"
version = "0.1.689"
version = "0.1.690"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
29 changes: 20 additions & 9 deletions pyk/src/pyk/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def default() -> dict[str, Any]:

@staticmethod
def update_args(parser: ArgumentParser) -> None:
parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output.')
parser.add_argument('--debug', action='store_true', help='Debug output.')
parser.add_argument('--verbose', '-v', default=None, action='store_true', help='Verbose output.')
parser.add_argument('--debug', default=None, action='store_true', help='Debug output.')


class OutputFileOptions(Options):
Expand Down Expand Up @@ -69,8 +69,10 @@ def default() -> dict[str, Any]:

@staticmethod
def update_args(parser: ArgumentParser) -> None:
parser.add_argument('--minimize', dest='minimize', action='store_true', help='Minimize output.')
parser.add_argument('--no-minimize', dest='minimize', action='store_false', help='Do not minimize output.')
parser.add_argument('--minimize', dest='minimize', default=None, action='store_true', help='Minimize output.')
parser.add_argument(
'--no-minimize', dest='minimize', default=None, action='store_false', help='Do not minimize output.'
)


class KDefinitionOptions(Options):
Expand Down Expand Up @@ -185,11 +187,16 @@ def update_args(parser: ArgumentParser) -> None:
parser.add_argument(
'--emit-json',
dest='emit_json',
default=None,
action='store_true',
help='Emit JSON definition after compilation.',
)
parser.add_argument(
'--no-emit-json', dest='emit_json', action='store_false', help='Do not JSON definition after compilation.'
'--no-emit-json',
dest='emit_json',
default=None,
action='store_false',
help='Do not JSON definition after compilation.',
)
parser.add_argument(
'-ccopt',
Expand All @@ -200,31 +207,35 @@ def update_args(parser: ArgumentParser) -> None:
parser.add_argument(
'--no-llvm-kompile',
dest='llvm_kompile',
default=None,
action='store_false',
help='Do not run llvm-kompile process.',
)
parser.add_argument(
'--with-llvm-library',
dest='llvm_library',
default=None,
action='store_true',
help='Make kompile generate a dynamic llvm library.',
)
parser.add_argument(
'--enable-llvm-debug',
dest='enable_llvm_debug',
default=None,
action='store_true',
help='Make kompile generate debug symbols for llvm.',
)
parser.add_argument(
'--read-only-kompiled-directory',
dest='read_only',
default=None,
action='store_true',
help='Generated a kompiled directory that K will not attempt to write to afterwards.',
)
parser.add_argument('-O0', dest='o0', action='store_true', help='Optimization level 0.')
parser.add_argument('-O1', dest='o1', action='store_true', help='Optimization level 1.')
parser.add_argument('-O2', dest='o2', action='store_true', help='Optimization level 2.')
parser.add_argument('-O3', dest='o3', action='store_true', help='Optimization level 3.')
parser.add_argument('-O0', dest='o0', default=None, action='store_true', help='Optimization level 0.')
parser.add_argument('-O1', dest='o1', default=None, action='store_true', help='Optimization level 1.')
parser.add_argument('-O2', dest='o2', default=None, action='store_true', help='Optimization level 2.')
parser.add_argument('-O3', dest='o3', default=None, action='store_true', help='Optimization level 3.')


class ParallelOptions(Options):
Expand Down
2 changes: 1 addition & 1 deletion pyk/src/pyk/kdist/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def update_args(parser: ArgumentParser) -> None:
action='append',
help='build with argument',
)
parser.add_argument('-f', '--force', action='store_true', help='force build')
parser.add_argument('-f', '--force', default=None, action='store_true', help='force build')
parser.add_argument('-j', '--jobs', metavar='N', type=int, help='maximal number of build jobs')

def exec(self) -> None:
Expand Down

0 comments on commit 0a16336

Please sign in to comment.