Skip to content

Commit

Permalink
changed the interface back to the old one. last time, i promise
Browse files Browse the repository at this point in the history
  • Loading branch information
mivanit committed Mar 18, 2022
1 parent edc1673 commit 64c8079
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,37 @@ this allows the user to reference the dendron notes instead of raw bibtex item (
## Usage:

- `gen` : generate reference notes:
generate reference notes:

```bash
python refs_vault_gen.py gen [cfg_path] [kwargs]
python refs_vault_gen.py [cfg_path] [--<kwarg>=<val>]
```

- `help` : print help message and exit:
`cfg_path` can be positional. If arguments are passed, the defaults are used. Notably:
```python
bib_filename : str = 'refs.bib'
vault_loc : str = 'vault/'
note_prefix : str = 'refs.'
```

### Help and configuration

- `--help` : print help message and exit:
```bash
python refs_vault_gen.py help
python refs_vault_gen.py --help
```

- `print_cfg` : print to console an example config in either json or yaml:
- `--print_cfg` : print to console an example config in either json or yaml (json by default):

```bash
python refs_vault_gen.py print_cfg [--fmt=<format>]
python refs_vault_gen.py --print_cfg [--fmt=<format>]
```

### Generation:

when running
```bash
python refs_vault_gen.py gen [cfg_path] [**kwargs]
python refs_vault_gen.py [cfg_path] [**kwargs]
```

`cfg_path` should be the location of a yaml or json config file
Expand Down
22 changes: 15 additions & 7 deletions dendron_citations/refs_vault_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def print_help():
print(__doc__)
sys.exit(0)

def print_cfg(fmt : str = 'json'):
def print_cfg(fmt : str):
"""prints the default config as either json or yaml"""
cfg : Config = Config()
if fmt.lower() == 'json':
Expand All @@ -701,15 +701,23 @@ def print_cfg(fmt : str = 'json'):
else:
raise ValueError(f'unknown format: {fmt}')

RUNME : Dict[str, Callable] = {
'gen' : gen,
'help' : print_help,
'print_cfg' : print_cfg,
}
def main(cfg_path : Optional[str] = None, **kwargs):
if 'help' in kwargs or 'h' in kwargs:
print_help()
elif 'print_cfg' in kwargs:
print_cfg(fmt = kwargs['fmt'] if 'fmt' in kwargs else 'json')
else:
gen(cfg_path, **kwargs)

# RUNME : Dict[str, Callable] = {
# 'gen' : gen,
# 'help' : print_help,
# 'print_cfg' : print_cfg,
# }

if __name__ == '__main__':
import fire # type: ignore
fire.Fire(RUNME)
fire.Fire(main)



Expand Down
4 changes: 2 additions & 2 deletions scripts/dendron_gen_refs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dendron_citations.refs_vault_gen import RUNME
from dendron_citations.refs_vault_gen import main

import fire
fire.Fire(RUNME)
fire.Fire(main)

0 comments on commit 64c8079

Please sign in to comment.