Config

Command Line Interface

Creating / Reading Config


source

save_config

 save_config (config)

Save config to file


source

load_config

 load_config ()

Load config, creating default if it doesn’t exist

Let’s try it out! Let’s see if we can save a config:

config = {'quarto-path':'/my/example/project/path','obsidian-path':'/path/to/my/valult'}

save_config(config)

Now, let’s try reading it and see if the file is the same:

t1 = load_config()
print(t1)
{'quarto-path': '/my/example/project/path', 'obsidian-path': '/path/to/my/valult'}
t1 = load_config()
print(t1)

test_eq(t1['obsidian-path'],config['obsidian-path'])
test_eq(t1['quarto-path'],config['quarto-path'])
print('\nIt works!')
{'quarto-path': '/my/example/project/path', 'obsidian-path': '/path/to/my/valult'}

It works!

Setting/Updating Values


source

set_setting

 set_setting (key, value)

Set a specific setting


source

get_setting

 get_setting (key, default=None)

Get a specific setting

Let’s see if these work!

set_setting('author','Cooper Richason')
t2 = get_setting('author')
print(t2)

test_eq('Cooper Richason',t2)
print('It works!')
Cooper Richason
It works!
# Cleaning up Tests
ct = load_config()
ct.pop('obsidian-path')
ct.pop('quarto-path')
ct.pop('author')
save_config(t1)