Skip to content

Commit

Permalink
release: 2022.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FredHappyface committed Dec 30, 2022
1 parent 4a34283 commit 009c629
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All major and minor version changes will be documented in this file. Details of
patch-level version changes can be found in [commit messages](../../commits/master).

## 2022.2.1 - 2022/12/30

- Fix https://github.com/FHPythonUtils/Cli2Gui/issues/13

## 2022.2 - 2022/09/02

- Fix https://github.com/FHPythonUtils/Cli2Gui/issues/10, basic support for subparsers. `parser.add_subparsers()`
Expand Down
24 changes: 13 additions & 11 deletions cli2gui/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,19 @@ def Click2Gui( # pylint: disable=invalid-name
Any: Runs the application
"""
bSpec = BuildSpec(
run_function,
ParserType.CLICK,
gui,
theme,
darkTheme,
sizes,
image,
program_name,
program_description,
max_args_shown,
menu,
**{
"run_function": run_function,
"parser": ParserType.CLICK,
"gui": gui,
"theme": theme,
"darkTheme": darkTheme,
"sizes": sizes,
"image": image,
"program_name": program_name,
"program_description": program_description,
"max_args_shown": max_args_shown,
"menu": menu,
}
)

buildSpec = createFromParser(
Expand Down
2 changes: 1 addition & 1 deletion documentation/reference/cli2gui/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Decorators

## Cli2Gui

[Show source in decorators.py:161](../../../cli2gui/decorators.py#L161)
[Show source in decorators.py:163](../../../cli2gui/decorators.py#L163)

Decorator to use in the function that contains the argument parser...

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cli2gui"
version = "2022.2"
version = "2022.2.1"
license = "mit"
description = "Use this module to convert a cli program to a gui"
authors = ["FredHappyface"]
Expand Down
14 changes: 10 additions & 4 deletions tests/argparse/test_10.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
from cli2gui import Cli2Gui
import argparse

from cli2gui import Cli2Gui


def run(args):
print(args)


def main():
parser = argparse.ArgumentParser(description="this is an example parser")
subparsers = parser.add_subparsers(help='types of A')
parser.add_argument("-v",)
subparsers = parser.add_subparsers(help="types of A")
parser.add_argument(
"-v",
)

a_parser = subparsers.add_parser("A")
b_parser = subparsers.add_parser("B")

a_parser.add_argument("something", choices=['a1', 'a2'])
a_parser.add_argument("something", choices=["a1", "a2"])

args = parser.parse_args()
run(args)


decorator_function = Cli2Gui(
run_function=run,
auto_enable=True,
Expand Down
24 changes: 14 additions & 10 deletions tests/argparse/test_11.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
from cli2gui import Cli2Gui
import argparse

from cli2gui import Cli2Gui


def run(args):
print(args.arg)
print(args.arg)


def main():
parser = argparse.ArgumentParser(description="this is an example parser")
parser.add_argument("--arg", type=str, default="foo", help="keyword arg")
parser.add_argument("--bool", action='store_true', default=True, help="boolean arg")
args = parser.parse_args()
run(args)
parser = argparse.ArgumentParser(description="this is an example parser")
parser.add_argument("--arg", type=str, default="foo", help="keyword arg")
parser.add_argument("--bool", action="store_true", default=True, help="boolean arg")
args = parser.parse_args()
run(args)


decorator_function = Cli2Gui(
run_function=run,
auto_enable=True,
run_function=run,
auto_enable=True,
)

gui = decorator_function(main)

if __name__ == "__main__":
gui()
gui()

0 comments on commit 009c629

Please sign in to comment.