Skip to main content

No project description provided

Project description

hledger-args

Description

In basic usage, this package is a replacement for hledger command file using custom directives inside the journal file, instead of referencing to a command args file.

In interactive mode, the user can create menus using placeholders. Each placeholders will become a prompt and be replaced by the value entered. So the user will be able to create a multi prompt report composed by fixed options already defined and leave some to the user each time this package is executed.

Interactive Mode

Instead of giving the the desired command thru a command-line argument, choose it by selecting from a menu using the flag --interactive

Special placeholders

Placeholders Description
{account} fuzzy search existing accounts
{payee} fuzzy search existing payee
{tag} fuzzy search existing tags and values
{tag_name} search tag name after "_" and fuzzy search existing values for this tag
{months} prompt initial and end dates both inclusive. Diferent from default hledger
{type} select between accounts type
{cur} fuzzy search existing commodities

Non hledger commands

It is possible to run other commands beside the default hledger. For that, name the arg as /shell_name/ and /hledger-args/ will execute it according to the conditions:

  • It can accept inputs from the terminal stdin.
  • The string /[file]/ will be replaces by the name of the "--file" option.
  • It will not be saved in PDF report

It is useful if you want to add a command that doesn't use hledger but needs the file name being used.

PDF output.

There are two ways to output the reports to pdf:

  • Option --pdf-file: Save the report to the specified file.
  • Option --pdf-dir: Save the report to a directory named after the current date under the specified directory. Creates it if doesn't exist. Should be used to keep a history of generated reports.

Installation

Dependencies

  • python 3.8
  • hledger

Installation command

pip install --upgrade hledger-args

Sub directive

Add lines according to the format below:

     #+args [command name]:[hledger options]
     #+args [other command_name]:[other hledger options]

Examples/Data

     #+args buy_aapl:bal desc:\"Buy AAPL\"
     #+args aapl_cur:bal desc:\"Buy AAPL\" cur:{commodity}

Usage

After adding the commands using sub directives, run hledger-args -f [journal file]. Without any option or argument, it output the existing ones divided between interactive and non interactive. Those with placeholders can only be on interactive-mode, so an error if be raised without the --interactive flag.

If not running on interactive mode, arguments after [NAME] are passed to hledger. If the name is all, output all no interactive reports

python -m hledger_args -h
                                                                                
 Usage: python -m hledger_args [OPTIONS] [NAME] [EXTRA_HLEDGER_OPTIONS]...      
                                                                                
 ────────────────────────────────────────────────────────────────────────────── 
 NAME: Command name to run saved in the journal sub directives. Not available   
 in Interactive mode                                                            
                                                                                
 EXTRA_HLEDGER_OPTIONS: Extra options to send to hledger command. Not available 
 in Interactive mode. The name "all" is special and output all the no           
 interactive commands.                                                          
                                                                                
 ────────────────────────────────────────────────────────────────────────────── 
 In basic usage, this package is a replacement for hledger argument file using  
 custom directives inside the journal file, instead of referencing to an        
 argument file                                                                  
                                                                                
 Interactive Mode: Instead of giving the desired command thru a command-line    
 argument, choose it by selecting from a menu using the flag --interactive      
                                                                                
 Placeholder Command Substitution: In Interactive Mode, a command can use       
 placeholders by putting them between curly braces and additional prompts wil   
 ask for the value and do the proper substitution                               
                                                                                
 Special Placeholders: {account}, {payee}, {tag}, {tag_name}, {months}, {type}, 
 {cur} are special placeholders that offers autocomplete with fuzzy search      
 using data from the journal. See the README for explanation on each of them    
                                                                                
 Sub directive format:                                                          
                                                                                
                                                                                
  #+args [command name]:[hledger options]                                       
  #+args [other command_name]:[other hledger options]                           
                                                                                
                                                                                
 Example:                                                                       
                                                                                
                                                                                
  #+args buy_aapl:bal desc:"Buy AAPL"                                           
  #+args aapl_cur:bal desc:"Buy AAPL" cur:{commodity}                           
                                                                                
                                                                                
╭─ Options ────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  *   --file                  -f   Inform the journal file path               │
│                                   (TEXT)                                     │
│                                   [required]                                 │
│                                                                              │
│      --interactive           -i   Run in interactive mode by answering the   │
│                                   prompts. [NAME] and                        │
│                                   [EXTRA_HLEDGER_OPTIONS] are not used in    │
│                                   this mode.                                 │
│                                                                              │
│      --pdf-dir               -d   Save the report to a folder named          │
│                                   according to the current date under the    │
│                                   specified directory                        │
│                                   (DIRECTORY)                                │
│                                                                              │
│      --pdf-file              -o   output the report to the specified file    │
│                                   in pdf                                     │
│                                   (FILE)                                     │
│                                                                              │
│      NAME                         (TEXT)                                     │
│                                                                              │
│      EXTRA_HLEDGER_OPTIONS        (TEXT)                                     │
│                                                                              │
│      --help                  -h   Show this message and exit.                │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hledger_args-0.0.8.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hledger_args-0.0.8-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file hledger_args-0.0.8.tar.gz.

File metadata

  • Download URL: hledger_args-0.0.8.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for hledger_args-0.0.8.tar.gz
Algorithm Hash digest
SHA256 d85c8030db1977906f5b17c1db6dbe5f86589270f09f592abd7c327f6d02b51f
MD5 a8d67055b8fe8ec8115c25a9813e695f
BLAKE2b-256 c1729dcdba38b83a1084c6047eaa40f53e33fb4824df9a646035d4a21212805d

See more details on using hashes here.

File details

Details for the file hledger_args-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: hledger_args-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for hledger_args-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bd10f953cec22021156933c866c090e0bc0ed431dc52f72daa2675ba7567fd6e
MD5 53fb9fdc48f4de24bc867c263ce3de5e
BLAKE2b-256 d41631323f5d6a5bdb2515e85593de40dfd7d6434110cf1a335acccfb8a817a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page