Fixed stdin reading and added update command
This commit is contained in:
parent
c74906fb77
commit
d2428f4d54
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env nu
|
#!/usr/bin/env -S nu --stdin
|
||||||
|
|
||||||
let configPath = $"($env.XDG_CONFIG_HOME? | default $"($env.HOME)/.config")/irs.toml"
|
let configPath = $"($env.XDG_CONFIG_HOME? | default $"($env.HOME)/.config")/irs.toml"
|
||||||
let config = if ($configPath | path exists) { open $configPath }
|
let config = if ($configPath | path exists) { open $configPath }
|
||||||
|
@ -98,6 +98,13 @@ def "main start" [--no-icon(-n) # Disables icon in notification
|
||||||
notify $"Starting playback of:\n(getCurrent $host)" (not $no_icon) $host
|
notify $"Starting playback of:\n(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Update the mpd database
|
||||||
|
def "main update" [--host(-H): string # mpd host
|
||||||
|
] {
|
||||||
|
let host = getHost $host
|
||||||
|
mpc update --host $host
|
||||||
|
}
|
||||||
|
|
||||||
# Toggles playback of the current que
|
# Toggles playback of the current que
|
||||||
def "main toggle" [--no-icon(-n) # Disables icon in notification
|
def "main toggle" [--no-icon(-n) # Disables icon in notification
|
||||||
--host(-H): string # mpd host
|
--host(-H): string # mpd host
|
||||||
|
@ -121,9 +128,10 @@ def "main insert" [ --host(-H): string # mpd host
|
||||||
, ...uri: string # URI to insert
|
, ...uri: string # URI to insert
|
||||||
] {
|
] {
|
||||||
let host = getHost $host
|
let host = getHost $host
|
||||||
|
let input = $in | to text
|
||||||
match ($uri | is-empty) {
|
match ($uri | is-empty) {
|
||||||
true => { $in | mpc insert --host $host }
|
true => { $input | mpc insert --host $host }
|
||||||
false => {mpc insert --host $host $uri }
|
false => { ($uri | to text) | mpc insert --host $host }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,9 +140,10 @@ def "main add" [ --host(-H): string # mpd host
|
||||||
, ...uri: string # URI to add
|
, ...uri: string # URI to add
|
||||||
] {
|
] {
|
||||||
let host = getHost $host
|
let host = getHost $host
|
||||||
|
let input = $in | to text
|
||||||
match ($uri | is-empty) {
|
match ($uri | is-empty) {
|
||||||
true => { $in | mpc add --host $host }
|
true => { $input | mpc add --host $host }
|
||||||
false => { mpc add --host $host $uri }
|
false => { ($uri | to text) | mpc add --host $host }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue