diff --git a/hledger/Hledger/Cli/Commands/Repl.md b/hledger/Hledger/Cli/Commands/Repl.md index 4aac5ed23..e088f8a0b 100644 --- a/hledger/Hledger/Cli/Commands/Repl.md +++ b/hledger/Hledger/Cli/Commands/Repl.md @@ -17,16 +17,15 @@ The commands will run more quickly than if run individually, because the input f Syntax of the commands is intentionally simple: - each line is a single hledger command -- lines that can't be interpreted as hledger commands are printed out as-is - empty lines are skipped - everything after `#` is considered to be a comment and will be ignored, and will not be printed out -- `echo ` will print out text, even if it could be recognized as a hledger command +- `echo ` will print out `` -You can use single or double quotes to quote aguments that need it ('like this' or "like this"). +You can use single or double quotes to quote arguments that need it ('like this' or "like this"). ### Caveats: -- `Repl`, like any other command, will load the input file(s) (specified by `LEDGER_JOURNAL` or by `-f` arguments). The contents of those files would be used by all the commands that `repl` runs. If you want a particular command to use a different input file, you can use `-f` flag for that particular command. This will override (not add) the input for that particular command. All the input files would be cached, and would be read only once. +- `Repl`, like any other command, will load the input file(s) (specified by `LEDGER_FILE` or by `-f` arguments). The contents of those files would be used by all the commands that `repl` runs. If you want a particular command to use a different input file, you can use `-f` flag for that particular command. This will override (not add) the input for that particular command. All the input files would be cached, and would be read only once. ### Examples: diff --git a/hledger/Hledger/Cli/Commands/Repl.txt b/hledger/Hledger/Cli/Commands/Repl.txt index f1ab6b6f8..6a524e332 100644 --- a/hledger/Hledger/Cli/Commands/Repl.txt +++ b/hledger/Hledger/Cli/Commands/Repl.txt @@ -17,19 +17,17 @@ The commands will run more quickly than if run individually, because the input files would be parsed only once. Syntax of the commands is intentionally simple: - each line is a single -hledger command - lines that can't be interpreted as hledger commands -are printed out as-is - empty lines are skipped - everything after # is +hledger command - empty lines are skipped - everything after # is considered to be a comment and will be ignored, and will not be printed -out - echo will print out text, even if it could be recognized as -a hledger command +out - echo will print out -You can use single or double quotes to quote aguments that need it +You can use single or double quotes to quote arguments that need it ('like this' or "like this"). Caveats: - Repl, like any other command, will load the input file(s) (specified - by LEDGER_JOURNAL or by -f arguments). The contents of those files + by LEDGER_FILE or by -f arguments). The contents of those files would be used by all the commands that repl runs. If you want a particular command to use a different input file, you can use -f flag for that particular command. This will override (not add) the diff --git a/hledger/Hledger/Cli/Commands/Run.md b/hledger/Hledger/Cli/Commands/Run.md index 2395df4fd..e951c41d5 100644 --- a/hledger/Hledger/Cli/Commands/Run.md +++ b/hledger/Hledger/Cli/Commands/Run.md @@ -11,21 +11,22 @@ no command-specific flags The commands will run more quickly than if run individually, because the input files would be parsed only once. -"run" has two ways of invocation: +"run" has three ways of invocation: - when all positional arguments of "run" are valid file names, "run" will read commands from these files, in order: `run -f some.journal file1.txt file2.txt file3.txt`. - commands could be specified directly on the command line. All commands (including the very first one) should be preceded by argument "--": `run -f some.journal -- cmd1 -- cmd2 -- cmd3`. +- it could also accept commands from standard input, if you don't provide an positional arguments and pipe commands into it. + Syntax of the command is intentionally simple: - each line read from a file is a single hledger command -- lines that can't be interpreted as hledger commands are printed out as-is - empty lines are skipped - everything after `#` is considered to be a comment and will be ignored, and will not be printed out -- `echo ` will print out text, even if it could be recognized as a hledger command +- `echo ` will print out `` - `run` is a valid command to use as well, so you can have `run` call `run` if you want to. -You can use single or double quotes to quote aguments that need it ('like this' or "like this"). +You can use single or double quotes to quote arguments that need it ('like this' or "like this"). You can use `#!/usr/bin/env hledger run` in the first line of the file to make it a runnable script. If this complains about "binary `hledger run` not found", use `/usr/bin/env -S hledger run`. @@ -33,11 +34,16 @@ You can use `#!/usr/bin/env hledger run` in the first line of the file to make i - If you meant to provide file name as an argument, but made a mistake and a gave file name that does not exist, "run" will attempt to interpret it as a command. -- `Run`, like any other command, will load the input file(s) (specified by `LEDGER_JOURNAL` or by `-f` arguments). The contents of those files would be used by all the commands that `run` runs. If you want a particular command to use a different input file, you can use `-f` flag for that particular command. This will override (not add) the input for that particular command. All the input files would be cached, and would be read only once. +- `Run`, like any other command, will load the input file(s) (specified by `LEDGER_FILE` or by `-f` arguments). The contents of those files would be used by all the commands that `run` runs. If you want a particular command to use a different input file, you can use `-f` flag for that particular command. This will override (not add) the input for that particular command. All the input files would be cached, and would be read only once. ### Examples: -To provide commands on the command line, separate them with `--`: +Pipe commands into `run`, one per line: +```cli +(echo "files"; echo "stats") | hledger repl -f some.journal +``` + +To provide commands on the command line, separate them with `--` (including the first one): ```cli hledger run -f some.journal -- balance assets --depth 2 -- balance liabilities -f /some/other.journal --depth 3 --transpose -- stats ``` diff --git a/hledger/Hledger/Cli/Commands/Run.txt b/hledger/Hledger/Cli/Commands/Run.txt index 0f058cb84..b68c32393 100644 --- a/hledger/Hledger/Cli/Commands/Run.txt +++ b/hledger/Hledger/Cli/Commands/Run.txt @@ -11,7 +11,7 @@ no command-specific flags The commands will run more quickly than if run individually, because the input files would be parsed only once. -"run" has two ways of invocation: +"run" has three ways of invocation: - when all positional arguments of "run" are valid file names, "run" will read commands from these files, in order: @@ -21,15 +21,16 @@ input files would be parsed only once. commands (including the very first one) should be preceded by argument "--": run -f some.journal -- cmd1 -- cmd2 -- cmd3. -Syntax of the command is intentionally simple: - each line read from a -file is a single hledger command - lines that can't be interpreted as -hledger commands are printed out as-is - empty lines are skipped - -everything after # is considered to be a comment and will be ignored, -and will not be printed out - echo will print out text, even if -it could be recognized as a hledger command - run is a valid command to -use as well, so you can have run call run if you want to. +- it could also accept commands from standard input, if you don't + provide an positional arguments and pipe commands into it. -You can use single or double quotes to quote aguments that need it +Syntax of the command is intentionally simple: - each line read from a +file is a single hledger command - empty lines are skipped - everything +after # is considered to be a comment and will be ignored, and will not +be printed out - echo will print out - run is a valid +command to use as well, so you can have run call run if you want to. + +You can use single or double quotes to quote arguments that need it ('like this' or "like this"). You can use #!/usr/bin/env hledger run in the first line of the file to @@ -43,7 +44,7 @@ Caveats: interpret it as a command. - Run, like any other command, will load the input file(s) (specified - by LEDGER_JOURNAL or by -f arguments). The contents of those files + by LEDGER_FILE or by -f arguments). The contents of those files would be used by all the commands that run runs. If you want a particular command to use a different input file, you can use -f flag for that particular command. This will override (not add) the @@ -52,7 +53,12 @@ Caveats: Examples: -To provide commands on the command line, separate them with --: +Pipe commands into run, one per line: + +(echo "files"; echo "stats") | hledger repl -f some.journal + +To provide commands on the command line, separate them with -- +(including the first one): hledger run -f some.journal -- balance assets --depth 2 -- balance liabilities -f /some/other.journal --depth 3 --transpose -- stats