GnuCash on the Command Line

From GnuCash
Jump to: navigation, search

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";
                        can be "stderr" or "stdout".

Price Quotes Retrieval Options:

 -Q [ --quotes ] arg    Execute price quote related commands. Currently only
                        one command is supported.
                          get: Fetch current quotes for all foreign currencies
                               and stocks in the given GnuCash datafile.
 --namespace arg        Regular expression determining which namespace
                        commodities will be retrieved for

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.