Comments (6)
How about (ignoring parent directories for now since this is complicated enough):
- use -f FILE if specified
- or $LEDGER_FILE if set
- or ./.hledger if it exists # NEW
- or alphanumerically first of ./THISYEAR*.{hledger,journal,ledger,j} # NEW
- or alphanumerically first of ./LATESTPREVYEAR*.{hledger,journal,ledger,j} # NEW
- or alphanumerically first of ./*.{hledger,journal,ledger,j} # NEW
- or $HOME/.hledger.journal
(There is a slight cost to adding a top-level including file: the top-level AKA primary file gets some special treatment, like being the default target for add
and hledger-web add form. .hledger could also be a symlink, avoiding that problem.)
[Edit:
- use -f FILE if specified
- or $LEDGER_FILE if set
- or ./.hledger{,.EXT} if it exists. (Optional extension allows it to be any hledger format, not just journal ?) NEW
- or alphanumerically first of
the latest non-future year journals (./YYYY*.{hledger,journal,ledger,j}
)
or any journals (./*.{hledger,journal,ledger,j}
)
(or other supported formats too ?)
NEW - or $HOME/.hledger.journal
]
from hledger.
I hear you @alerque. That's true, hledger currently prioritises ease of working with "user's journal", not a project-scoped journal. The latter is a more advanced use case for technical users, but perhaps adding more support for it would not disturb the former.
Let's not if we don't need to though. So alternatives include
- #1013's shell one-liner that emulates config file support
- Using a consistent journal file name across projects, and aliasing "hledger -f main.ledger" or setting LEDGER_FILE to "main.ledger"
- Automatically setting LEDGER_FILE in project directories, using direnv or similar
It sounds like these aren't working for you because you want this feature usable by others (not just yourself) and they are all too much overhead ?
from hledger.
Brainstorming more alternatives:
- Add the hledger command as a shebang line in project journals so they can be accessed uniformly by executing them
- Add some heuristic to hledger that prioritises a local journal file, without configuration. Eg, use the alphabetically first (and if the file names begin with YYYY, prefer the current, otherwise the latest, year)
*.hledger
,*.journal
,*.ledger
or*.j
file in the current directory or above (if LEDGER_FILE is unset ?).
from hledger.
Using hledger as a shebang is an interesting idea. In fact it already works!
#!/usr/bin/env -S hledger -f
The caveat of course is that you have to set an executable bit on a data file. Given the file may import un-escaped data that gets saved via a web API it seems a bit sketchy.
My suggestion would be to have some default ledger file read from the CWD provided LEDGER_FILE
is not set. This wouldn't need to be variable like an alphabetical first match, just a fixed name that could serve as a place to import other files if necessary: default.hledger
or .hledger
or something of that nature... that could be excused in a non-english project where the actual data file might have a different name and is just pulled in via include real_main_file.ledger
or whatever.
from hledger.
from hledger.
I think option no. 3 is a good one: one can always symlink .hledger
to point it to their main journal file (and in filesystems with no support for symlinks, a simple include main.journal
would suffice).
While all the other additional options presented (4..7) are nice additions, they don't seem to bring as much value as option no. 3, since it largely depends on the user's journal/directory organization (eg. one can have YYYY/bank-MM.journal
files, easily). They're an interesting addition, I'm just not sure they're actually worth the effort at this stage.
from hledger.
Related Issues (20)
- date2-format for date2, CSV import HOT 1
- Inconsistent Decimal Mark Handling after CSV Import with Rules HOT 2
- 1.25: balance reports' HTML output stopped showing digit group marks HOT 1
- roi command includes unwanted amounts when given a period and dates on postings. HOT 6
- `stack8.10.yaml`, build failure `NonEmpty` does not export `singleton` HOT 3
- incorrect prices for "daily" roi HOT 8
- Install instruction under Linux with release 1.34 HOT 1
- tldr clients and documentation HOT 4
- Account type tag inconsistently recognized when declared in multiple files HOT 8
- `check` command should not stop after the first error HOT 4
- `--historical` uses period-end valuations of prices, while `--cumulative` doesn't HOT 15
- Ledger file formatting tool HOT 3
- Importing CSV: Creating complex `*.csv.rules` needs clarity HOT 6
- Code for Postings HOT 3
- ledger import not assigning default account2 as per manual HOT 3
- aregister -P, -C and -U miscalculate initial balance HOT 5
- UI bug in hledger web - autocomplete not working on the 5th account field and beyond HOT 1
- NBSP parsing seems to be broken (at least in CSV) HOT 1
- "every Nth day" periodic rule violating start date HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hledger.