Skip to content

Commit

Permalink
fix: Rename command to actualpy and set-context to use-context
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanelli committed Oct 4, 2024
1 parent e118f25 commit 89083c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion actual/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def init(


@app.command()
def set_context(context: str = typer.Argument(..., help="Context for this budget context")):
def use_context(context: str = typer.Argument(..., help="Context for this budget context")):
"""Sets the default context for the CLI."""
if context not in config.budgets:
raise ValueError(f"Context '{context}' is not registered. Choose one from {list(config.budgets.keys())}")
Expand All @@ -96,6 +96,7 @@ def set_context(context: str = typer.Argument(..., help="Context for this budget

@app.command()
def remove_context(context: str = typer.Argument(..., help="Context to be removed")):
"""Removes a configured context from the configuration."""
if context not in config.budgets:
raise ValueError(f"Context '{context}' is not registered. Choose one from {list(config.budgets.keys())}")
config.budgets.pop(context)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
},
entry_points="""
[console_scripts]
actual=actual.cli.main:app
actualpy=actual.cli.main:app
""",
)
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ def test_init_interactive(actual_server, mocker):
mock_prompt = mocker.patch("typer.prompt")
mock_prompt.side_effect = [f"http://localhost:{port}", "mypass", 2, "mypass", "myextra"]
assert invoke(["init"]).exit_code == 0
assert invoke(["set-context", "myextra"]).exit_code == 0
assert invoke(["set-context", "test"]).exit_code == 0
assert invoke(["use-context", "myextra"]).exit_code == 0
assert invoke(["use-context", "test"]).exit_code == 0
# remove extra context
assert invoke(["remove-context", "myextra"]).exit_code == 0
# different context should not succeed
assert invoke(["set-context", "myextra"]).exit_code != 0
assert invoke(["use-context", "myextra"]).exit_code != 0
assert invoke(["remove-context", "myextra"]).exit_code != 0


Expand Down

0 comments on commit 89083c1

Please sign in to comment.