Difference between revisions of "GnuCash on the Command Line"

From GnuCash
Jump to: navigation, search
(Fix Bug 798768.)
(Add new gnucash-cli quote options.)
Line 29: Line 29:
 
   -Q [ --quotes ] arg    Execute price quote related commands. Currently only
 
   -Q [ --quotes ] arg    Execute price quote related commands. Currently only
 
                         one command is supported.
 
                         one command is supported.
 +
 +
                          info: Show Finance::Quote version and exposed quote
 +
                                sources.
  
 
                           get: Fetch current quotes for all foreign currencies
 
                           get: Fetch current quotes for all foreign currencies
 
                                 and stocks in the given GnuCash datafile.
 
                                 and stocks in the given GnuCash datafile.
  
 +
                          dump: Fetch current quotes for specified currencies
 +
                                or stocks from a specified namespace and print
 +
                                the results to the console.
 +
                                This must be followed with a source and one or
 +
                                more symbols, unless the source is "currency"
 +
                                in which case it must be followed with two or
 +
                                more symbols, the first of which is the
 +
                                currency in which exchange rates for the rest
 +
                                will be quoted.
 
   --namespace arg        Regular expression determining which namespace
 
   --namespace arg        Regular expression determining which namespace
 
                         commodities will be retrieved for
 
                         commodities will be retrieved for
 +
 +
  -V [ --verbose ]      When using the dump command list all of the parameters
 +
                        Finance::Quote returns for the symbol instead of the
 +
                        ones that Gnucash requires.
  
 
Report Generation Options:
 
Report Generation Options:

Revision as of 19:57, 31 March 2023

GnuCash has a command-line interface for use in scripts or for performing quick tasks without launching the graphic interface. Note that

To see the options for the current version use the command gnucash-cli --help. At version 4.11 this produces the following: bin/gnucash-cli [options] [datafile] - GnuCash, accounting for personal and small business finance:

Common Options:

 -h [ --help ]          Show this help message
 -v [ --version ]       Show GnuCash version
 --debug                Enable debugging mode: provide deep detail in the
                        logs.
                        This is equivalent to: --log "=info" --log "qof=info"
                        --log "gnc=info"
 --extra                Enable extra/development/debugging features.
 --log arg              Log level overrides, of the form
                        "modulename={debug,info,warn,crit,error}"
                        Examples: "--log qof=debug" or "--log
                        gnc.backend.file.sx=info"
                        This can be invoked multiple times.
 --paths                Show paths
 --logto arg            File to log into; defaults to "/tmp/gnucash.trace" on most Unix,
                        "%LOCALAPPDATA%\Temp\gnucash.trace.XXXXXX.log", where XXXXXX is 
                        replaced with random characters, on Microsoft Windows, and
                        "$TMPDIR/gnucash.trace" on macOS;
                        use "stderr" or "stdout" to write to the terminal or any file path to
                        override the default.

Price Quotes Retrieval Options:

 -Q [ --quotes ] arg    Execute price quote related commands. Currently only
                        one command is supported.
                          info: Show Finance::Quote version and exposed quote
                                sources.
                          get: Fetch current quotes for all foreign currencies
                               and stocks in the given GnuCash datafile.
                         dump: Fetch current quotes for specified currencies
                                or stocks from a specified namespace and print
                                the results to the console.
                                This must be followed with a source and one or
                                more symbols, unless the source is "currency"
                                in which case it must be followed with two or
                                more symbols, the first of which is the
                                currency in which exchange rates for the rest
                                will be quoted.
 --namespace arg        Regular expression determining which namespace
                        commodities will be retrieved for
 -V [ --verbose ]       When using the dump command list all of the parameters
                        Finance::Quote returns for the symbol instead of the
                        ones that Gnucash requires.

Report Generation Options:

 -R [ --report ] arg    Execute report related commands. The following
                        commands are supported.
                          list: Lists available reports.
                          show: Describe the options modified in the named
                                report. A datafile may be specified to
                                describe some saved options.
                          run: Run the named report in the given GnuCash
                               datafile.
 --name arg             Name of the report to run
 --export-type arg      Specify export type
 --output-file arg      Output file for report

The datafile can be either a normal file path or a URI. The URI format is scheme://[[username[:password]@]hostname[:port]]/path where scheme is one of file, mysql, or postgres. mysql and postgres require the hostname including the username and password. The port is needed only if different from the IETF well known ones for the scheme; the path for those two schemes will be the database name supplied when you created the database.