Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: specify option types explicitly #179

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Specify <torrent-id> as one of:
* info hash (hex string)

Commands:
webtorrent download [torrent-ids...] Download a torrent [default]
webtorrent download [torrent-ids...] Download a torrent [default]
webtorrent downloadmeta <torrent-ids...> Download metadata of torrent
webtorrent seed <inputs...> Seed a file or a folder
webtorrent create <input> Create a .torrent file
Expand All @@ -91,40 +91,41 @@ Commands:
webtorrent help Show help information

Options (streaming):
--airplay Apple TV
--chromecast Google Chromecast [default: all]
--dlna DNLA
--mplayer MPlayer
--mpv MPV
--omx OMX [default: hdmi]
--vlc VLC
--iina IINA
--smplayer SMPlayer
--xbmc XBMC
--stdout Standard out (implies --quiet)
--airplay Apple TV [boolean]
--chromecast Google Chromecast [default: all]
--dlna DNLA [boolean]
--mplayer MPlayer [boolean]
--mpv MPV [boolean]
--omx OMX [default: hdmi]
--vlc VLC [boolean]
--iina IINA [boolean]
--smplayer SMPlayer [boolean]
--xbmc XBMC [boolean]
--stdout Standard out (implies --quiet) [boolean]

Options (simple):
-o, --out Set download destination [string]
-s, --select Select specific file in torrent
-t, --subtitles Load subtitles file [string]
-h, --help Show help information [boolean]
-v, --version Show version information [boolean]
-o, --out Set download destination [string]
-s, --select Select specific file in torrent [default: List files]
-t, --subtitles Load subtitles file [string]
-h, --help Show help information [boolean]
-v, --version Show version information [boolean]

Options (advanced)
-p, --port Change the http server port [default: 8000]
-b, --blocklist Load blocklist file/url [string]
-a, --announce Tracker URL to announce to [string]
-q, --quiet Don't show UI on stdout
--pip Enter Picture-in-Picture if supported by the player
--verbose Show torrent protocol details
--player-args Add player specific arguments (see example) [string]
--torrent-port Change the torrent seeding port [default: random]
--dht-port Change the dht port [default: random]
--not-on-top Don't set "always on top" option in player
--keep-seeding Don't quit when done downloading
--no-quit Don't quit when player exits
--on-done Run script after torrent download is done
--on-exit Run script before program exit
-p, --port Change the http server port [number] [default: 8000]
-b, --blocklist Load blocklist file/url [string]
-a, --announce Tracker URL to announce to [string]
-q, --quiet Don't show UI on stdout [boolean]
--pip Enter Picture-in-Picture if supported by the player [boolean]
--verbose Show torrent protocol details [boolean]
--playlist Open files in a playlist if supported by the player [boolean]
--player-args Add player specific arguments (see example) [string]
--torrent-port Change the torrent seeding port [number] [default: random]
--dht-port Change the dht port [number] [default: random]
--not-on-top Don't set "always on top" option in player [boolean]
--keep-seeding Don't quit when done downloading [boolean]
--no-quit Don't quit when player exits [boolean]
--on-done Run script after torrent download is done [string]
--on-exit Run script before program exit [string]
```

To download a torrent:
Expand Down
45 changes: 23 additions & 22 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,40 @@ const { version: webTorrentVersion } = require('webtorrent/package.json')
// Group options into sections (used in yargs configuration)
const options = {
streaming: {
airplay: { desc: 'Apple TV' },
airplay: { desc: 'Apple TV', type: 'boolean' },
chromecast: { desc: 'Google Chromecast', defaultDescription: 'all' },
dlna: { desc: 'DNLA' },
mplayer: { desc: 'MPlayer' },
mpv: { desc: 'MPV' },
dlna: { desc: 'DNLA', type: 'boolean' },
mplayer: { desc: 'MPlayer', type: 'boolean' },
mpv: { desc: 'MPV', type: 'boolean' },
omx: { desc: 'OMX', defaultDescription: 'hdmi' },
vlc: { desc: 'VLC' },
iina: { desc: 'IINA' },
smplayer: { desc: 'SMPlayer' },
xbmc: { desc: 'XBMC' },
stdout: { desc: 'Standard out (implies --quiet)' }
vlc: { desc: 'VLC', type: 'boolean' },
iina: { desc: 'IINA', type: 'boolean' },
smplayer: { desc: 'SMPlayer', type: 'boolean' },
xbmc: { desc: 'XBMC', type: 'boolean' },
stdout: { desc: 'Standard out (implies --quiet)', type: 'boolean' }
},
simple: {
o: { alias: 'out', desc: 'Set download destination', type: 'string', requiresArg: true },
s: { alias: 'select', desc: 'Select specific file in torrent' },
s: { alias: 'select', desc: 'Select specific file in torrent', defaultDescription: 'List files' },
t: { alias: 'subtitles', desc: 'Load subtitles file', type: 'string', requiresArg: true }
},
advanced: {
p: { alias: 'port', desc: 'Change the http server port', default: 8000, requiresArg: true },
p: { alias: 'port', desc: 'Change the http server port', type: 'number', default: 8000, requiresArg: true },
b: { alias: 'blocklist', desc: 'Load blocklist file/url', type: 'string', requiresArg: true },
a: { alias: 'announce', desc: 'Tracker URL to announce to', type: 'string', requiresArg: true },
q: { alias: 'quiet', desc: 'Don\'t show UI on stdout' },
pip: { desc: 'Enter Picture-in-Picture if supported by the player' },
verbose: { desc: 'Show torrent protocol details' },
playlist: { desc: 'Open files in a playlist if supported by the player' },
q: { alias: 'quiet', desc: 'Don\'t show UI on stdout', type: 'boolean' },
pip: { desc: 'Enter Picture-in-Picture if supported by the player', type: 'boolean' },
verbose: { desc: 'Show torrent protocol details', type: 'boolean' },
playlist: { desc: 'Open files in a playlist if supported by the player', type: 'boolean' },
'player-args': { desc: 'Add player specific arguments (see example)', type: 'string', requiresArg: true },
'torrent-port': { desc: 'Change the torrent seeding port', defaultDescription: 'random' },
'dht-port': { desc: 'Change the dht port', defaultDescription: 'random' },
'not-on-top': { desc: 'Don\'t set "always on top" option in player' },
'keep-seeding': { desc: 'Don\'t quit when done downloading' },
'no-quit': { desc: 'Don\'t quit when player exits' },
'torrent-port': { desc: 'Change the torrent seeding port', defaultDescription: 'random', type: 'number', requiresArg: true },
'dht-port': { desc: 'Change the dht port', defaultDescription: 'random', type: 'number', requiresArg: true },
'not-on-top': { desc: 'Don\'t set "always on top" option in player', type: 'boolean' },
'keep-seeding': { desc: 'Don\'t quit when done downloading', type: 'boolean' },
'no-quit': { desc: 'Don\'t quit when player exits', type: 'boolean' },
quit: { hidden: true, default: true },
'on-done': { desc: 'Run script after torrent download is done', requiresArg: true },
'on-exit': { desc: 'Run script before program exit', requiresArg: true }
'on-done': { desc: 'Run script after torrent download is done', type: 'string', requiresArg: true },
'on-exit': { desc: 'Run script before program exit', type: 'string', requiresArg: true }
}
}

Expand Down Expand Up @@ -109,6 +109,7 @@ process.on('SIGINT', gracefulExit)
process.on('SIGTERM', gracefulExit)

yargs
.wrap(Math.min(100, yargs.terminalWidth()))
.scriptName('webtorrent')
.locale('en')
.fail((msg, err) => { console.log(chalk`\n{red Error:} ${msg || err}`); process.exit(1) })
Expand Down