Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command: "run" #2323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

New command: "run" #2323

wants to merge 1 commit into from

Conversation

adept
Copy link
Collaborator

@adept adept commented Feb 11, 2025

Adds a new command, "run", that allows one to run hledger commands in interactive REPL or from command/script files:

#!/usr/bin/env hledger run
echo "Depth 1:"
balance assets --depth 1

echo "Depth 2:"
balance assets --depth 2

echo "Depth 3:"
balance assets --depth 3

echo "Uncategorized expenses:"
print expenses:unknown

@adept adept force-pushed the multi-step branch 5 times, most recently from f0df695 to 4f2c303 Compare February 11, 2025 18:35
@adept adept changed the title New script "multi-step" New command: "run" Feb 11, 2025
@jokesper
Copy link

Why not use a standard bash script?

@adept
Copy link
Collaborator Author

adept commented Feb 11, 2025

Why not use a standard bash script?

to avoid re-parsing the same journal file (quite large, in my case) over and over and over again.

If that's not a concern, then bash script is the (better?) alternative

@simonmichael
Copy link
Owner

Why not use a standard bash script?

We can also say, for the REPL - allowing fast interactive reporting sessions without rereading the data, which could be helpful if it's large.

We had GHCI already as a REPL for the haskell API, but this one is much more like the familiar command line (though not identical).

@simonmichael
Copy link
Owner

simonmichael commented Feb 11, 2025

We could also leave this as an add-on command. What might be some arguments against making it a builtin ?

  • I hope in future we can speed up hledger more, perhaps with caching, which might reduce the benefit of this command a bit. It might be a temporary fix, not long term need.

  • We might feel concerned about scope creep, adding complexity and dev distractions, and inventing our own custom scripting language.

Arguments for:

  • Built in commands get used and improved, addons don't

  • We might find some cool enhancement ideas

  • Optimisation might not happen, and even if it does there's always sufficiently large data / slow machines to appreciate a speed up

  • Avoiding wasted work, eg when generating scripted reports, is simply good economy of resources

  • Ledger and Beancount both provide such a REPL, for similar reasons presumably, though I don't hear these REPLs discussed.

  • This is extending a capability already present in hledger-ui and hledger-web, to the CLI.

  • It's a step towards better support for complex/compound reports.

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. performance Anything performance-related (run time, memory usage, disk space..) labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. performance Anything performance-related (run time, memory usage, disk space..)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants