-
Notifications
You must be signed in to change notification settings - Fork 2
API_Unified
Shae edited this page Oct 26, 2022
·
1 revision
This adds a unified interface for common tasks, such as downloads in order to ease package development.
Default: nu's integrated fetch
command
unified download [ARGUMENTS] URL [SAVE_LOCATION]
ARGUMENTS:
--headers: record = {}
the http-request headers
example: {DNT: 1, Accept: 'application/json'}
--timeout: int = 30
timeout in seconds
URL: string
the url you want to download
SAVE_LOCATION: path = '.'
where do you want to save the file?
if the save-location exists and is a directory it will
auto-determine the filename and save it in the directory.
otherwise it will create the location as file.
it is recommended to use filepaths in scripts since some
directories might unexpectedly not exist or the name-detection
might screw something up.
examples:
unified download https://www.gnu.org/fun/jokes/ed-msg.html
unified download https://www.gnu.org/fun/jokes/ed-msg.html ~/Downloads/
unified download https://www.gnu.org/fun/jokes/ed-msg.html ~/Downloads/ED.html
Just overwrite $env.NU_PACKER_UNIFIED.download
with a
code-block with the arguments url
, dir
, file
, headers
, timeout
Example (for aria2c
):
let-env NU_PACKER_UNIFIED = (
$env.NU_PACKER_UNIFIED
| update downloader {
{|url,dir,file,headers,timeout|
(aria2c --quiet
--dir $dir --out $file
--timeout $timeout
($headers
| transpose key value
| each {|i| $'--header "($i.key): ($i.value)"'}
)
$url
)
}
}
)
Supported by the default (chosen based on $env.EDITOR
):
-
vi
,vim
,nvim
emacs
ne
-
nano
(fallback)
unified editor FILE [LINE]
FILE: path
the file you want to edit
LINE: int
the linenumber which should be opened