Skip to content

Commit

Permalink
fix: Write brief documentation about cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanelli committed Oct 4, 2024
1 parent 89083c1 commit 4e95752
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ If you want to have the latest git version, you can also install using the repos
pip install git+https://github.com/bvanelli/actualpy.git
```

For querying basic information, you additionally install the CLI, checkout the
[basic documentation](https://actualpy.readthedocs.io/en/latest/command-line-interface/)

# Basic usage

The most common usage would be downloading a budget to more easily build queries. This would you could handle the
Expand Down
2 changes: 1 addition & 1 deletion actual/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def default_config_path():
return Path.home() / ".actual" / "config.yaml"
return Path.home() / ".actualpy" / "config.yaml"


class OutputType(Enum):
Expand Down
48 changes: 48 additions & 0 deletions docs/command-line-interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Command line interface

You can try out `actualpy` directly without the need if writing a custom script. All you need to do is install the
command line interface with:

```bash
pip install "actualpy[cli]"
```

You should then be able to generate exports directly:

```console
$ actualpy init
Please enter the URL of the actual server [http://localhost:5006]:
Please enter the Actual server password:
(1) Test
Please enter the budget index: 1
Name of the context for this budget [test]:
Initialized budget 'test'
$ actualpy export
Exported budget 'Test' (budget id 'My-Finances-0b46239') to '2024-10-04-1438-Test.zip'.
```

The configuration will be saved on the folder `.actualpy/config.yaml`. Check full help for more details:

```console
$ actualpy --help

Usage: actualpy [OPTIONS] COMMAND [ARGS]...

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --output -o [table|json] Output format: table or json [default: table] │
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ accounts Show all accounts. │
│ export Generates an export from the budget (for CLI backups). │
│ init Initializes an actual budget config interactively if options are not provided. │
│ metadata Displays all metadata for the current budget. │
│ payees Show all payees. │
│ remove-context Removes a configured context from the configuration. │
│ transactions Show all transactions. │
│ use-context Sets the default context for the CLI. │
│ version Shows the library and server version. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_init_interactive(actual_server, mocker):
def test_load_config(actual_server):
cfg = Config.load()
assert cfg.default_context == "test"
assert str(default_config_path()).endswith(".actual/config.yaml")
assert str(default_config_path()).endswith(".actualpy/config.yaml")
# if the context does not exist, it should fail to load the server
cfg.default_context = "foo"
with pytest.raises(ValueError, match="Could not find budget with context"):
Expand Down

0 comments on commit 4e95752

Please sign in to comment.