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

directives don't affect other journal files #510

Open
simonmichael opened this issue Feb 11, 2017 · 3 comments
Open

directives don't affect other journal files #510

simonmichael opened this issue Feb 11, 2017 · 3 comments

Comments

@simonmichael
Copy link
Owner

@simonmichael simonmichael commented Feb 11, 2017

In the report linked at https://twitter.com/LedgerTips/status/830238616261586945, I wanted to apply some journal directives to affect formatting of the output. I expected this to work:

$ echo "commodity 0,000,000 bytes" > tarsnap.preamble.journal
$ hledger -f tarsnap.preamble.journal -f tarsnap.csv bal

It didn't, nor does hledger -f tarsnap.preamble.journal -f tarsnap.journal ..., because directives affect only the file they are in, and not other files specified with additional -f arguments.

Ideally, this would just work, but there might be some complexities. Should directives affect subsequent files on the command line, or all files specified ? Should they affect just journal files, or all file types ? Would some directives work differently from others ? (Eg some directives are location-independent and some are not.)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ony
Copy link
Collaborator

@ony ony commented Feb 12, 2017

I thought this was a feature. You can have a separate file for your vacation expenses where you use different aliases. Note that includes inside of the file with directives will be affected also. This allows you to have a hierarchy of files and apply stuff only at some level.

Unless there will be directives like begin tag/end tag and begin alias/end alias I wouldn't like to loose such functionality.

Other option would be to use export or alike prefix for directives to make them global.

@5472qaywsx
Copy link

@5472qaywsx 5472qaywsx commented Dec 16, 2020

...once I understood this behavior with regard to account aliases, I ended up with this explanation for this: included files in hledger are like parallel circuits, and the directives are not shared between them / the included files; they have to be defined in the main file, only then they are inherited.

This is different from ledger-cli, where i.e. account aliases of included files are propagated to every other file of the tree / bunch.

I like to have a separate accounts.journal file with my chart of accounts and account alias definition.
If I put that file as an included file of my main.journal, ledger-cli substitutes the alias in every included file, hledger doesn't.

I ended up with reiterating the account alias definition from my accounts.journal into the main.journal, so I can play with both programs.

@simonmichael
Copy link
Owner Author

@simonmichael simonmichael commented Dec 16, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants