When listening to podcast, I like to download some episode up front.
@podcast.command()
@option('--number', type=int, default=10, help='How many episodes to download at once')
def download(number):
'Downloading podcasts'
print(f'Downloading {number} episodes')
clk podcast download
#+RESULTS[9e5e1cc779f8de092e883043b56d2327a255009c]: tryit
Downloading 10 episodes
Now, I want this command to be wrapped into an alias to ease making it part of more complicated flows. I want to control the number of podcast to download using an environment variable, hence the use of the ‘tpl:’ pattern appears appropriate.
clk alias set podcast.dwim echo 'Would do something before' , podcast download --number 'noeval:tpl:{NUMBER_TO_DOWNLOAD}' , echo 'would do something after'
#+RESULTS[878bae04a233b829b08b4b6deaa8bbec63a73d61]: makeitalias
New global alias for podcast.dwim: echo Would do something before , podcast download --number tpl:{NUMBER_TO_DOWNLOAD} , echo would do something after
Then I can call it with:
export NUMBER_TO_DOWNLOAD=100
clk podcast dwim
#+RESULTS[c0212f3e26f682e0699a082e7dcf612ef0794f12]: callit
Would do something before Downloading 100 episodes would do something after
Note that it needs the environment variable to be set, or it will raise an error.