command line (was Thanks GNUCash)

Neil Williams linux at codehelp.co.uk
Thu Jul 14 19:10:58 EDT 2005


On Tuesday 12 July 2005 11:58 pm, Robert Heller wrote:
> w> Sure, but we wouldn't recommend the CLI for everyday use.

I'd probably use it 4 days out of 7, but I'd only merge the data back into 
GnuCash perhaps once or twice a month - when I had a statement to reconcile.

I expect to be able to use CashUtil with Pilot-QOF so that a sync with the PDA 
updates the CLI data - in a single event - usually once daily. Unfortunately, 
there has been so much work involved in getting to this point that this 
probably won't be seamless by the time G2 is released. I hope I can, but 
currently I expect to need a sequence of commands to update from the PDA. 
That's the price of making the methods generic.

> Of course not!  The only thing *I* would use it for a quick bulk entry
> of simple transactions, something like:
>
> gnucash -importSimpleTransactions -
> /home/heller/Finances/Checking2005/Jan2005.xac 
> 7/7/2005 
> Ritz - pictures
> 18.20
> checking
> random expenses
> 7/7/2005
> Walmart - Drill and Bits
> 52.30
> checking
> tools
> ^D

I know that was off-the-cuff, but you'll need a bit more data than that - each 
line must have meaning. That listing would imply some kind of fixed data 
entry sequence, akin to CSV - it could be done by indicating what is expected 
next with some kind of shell prompt but it's too arbitrary / free format as 
it stands.

I hate to give an example at this v.early stage, it could be quite different 
by the time it's released!

So far (best viewed in fixed font as with ascii art):
  -i, --input=filename        Query the QSF XML in <filename>
  -l, --list                  List all databases supported by the current QOF
                              framework and exit.
  --explain                   List the fields within the specified database
                              and exit, requires -d.
  -t, --date=string           Shorthand to only query objects that contain the
                              specified date.
  -d, --database=string       Shorthand to only query objects within one
                              specific supported database.
  -e, --exclude=string        Shorthand to exclude a supported database from
                              the query.
  -s, --sql=string            Specify a SQL query on the command line.
  -f, --sql-file=filename     Specify one or more SQL queries contained in a
                              file.
  -w, --write=filename        Write the results of any query to the file
  --shell                     Enter the QOF interactive shell
  -?, --help                  Help
  --version                   CashUtil version information.

shell commands:
  add     [object]        Add a new instance of the object.
  edit    [object]        Select one instance and edit the parameter values.
  delete  [object]        Select one instance for deletion.
  list                    Synonym for the --list command but inside the shell.
  print   [object]        Select one instance and print the parameter values.
  explain [object]        Synonym for the --explain command inside the shell.
  load    [filename]      Replace the current book with data from the file.
                              Prompt to save the current book, if any.
  write   [filename]      Write out the current book. If no filename is given,
                              write to the original file.
                              (uses STDOUT if STDIN is used.)
  merge   [filename]      Merge data from the file into the current book.
  sql                     Run a SQL statement within the shell.
  help | ?                This screen.

Deletion would only make sense for new data - deleting something that exists 
in GnuCash would simply leave the original untouched when merging. Deleting 
an entity edited in the CLI could be a form of undo.

The real CLI interface *might* be, using shell prompts:

$ cashutil --shell
cashutil> load /home/user/money/thisyear.xml
cashutil> add Trans
cu:Trans> edit date_entered = today
cu:Trans> edit desc = "Ritz - pictures"
cu:Trans>add Split
cu:Split> edit amount = 18.20
cu:Split> edit account
cu:Account> ? not sure on this, maybe a selection, maybe some form of 
look-ahead of existing accounts in the QSF, defaults, config prefs ...
cu:Trans> done (i.e. use defaults for remaining parameters, if any)
cashutil> write
cashutil> quit
$

I will investigate tab completion of parameter names and I'd aim to have 
readline support for command histories within the shell (ala bash).

There may be a 'select [account]' option in there to set the current account - 
a bit like opening an Account window - leaving the user to only set the 
destination account. I may hide Split behind Trans so that a Trans acts as it 
does in the GUI - splits only appear to the user if the user requests a 
visible split.

Finally, an option to write out a series of SQL statements to replicate the 
previous shell session to be repeated at a later date could also be provided 
- a form of recording / macro expressed in SQL.

Or use the CLI via the SQL methods:

cashutil --input money/thisyear.xml --sql-file money/new.sql \ 
--write money/thisyear.xml

These would be good for automating report generation, repeating shell sessions 
and scripting the addition of new data.

or perhaps:
cashutil -f ./report.sql < money/current.xml > money/new.xml

-- 

Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-user/attachments/20050715/4ebdb077/attachment.bin


More information about the gnucash-user mailing list