feat: Implement --help
This commit is contained in:
parent
d8ddc8001a
commit
f9beb23d44
|
@ -7,7 +7,7 @@ import 'package:funkblubber/parsing/parser.dart' as parser;
|
||||||
void main(final List<String> arguments) async {
|
void main(final List<String> arguments) async {
|
||||||
final result = parser.extract(arguments);
|
final result = parser.extract(arguments);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
console.error("'funkblubber --help 'for more");
|
console.error("'funkblubber --help' for more");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,44 @@ ParseResult extract(final List<String> args) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onHelpStage() {
|
||||||
|
final String help = '''
|
||||||
|
usage: funkblubber [[-OPTIONS|URL]...]
|
||||||
|
|
||||||
|
A simple CLI for interaction with your Funkwhale account.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
[-a|--album ID] Provide with album ID to download it.
|
||||||
|
|
||||||
|
[-A|--artist ID] Provide with artist ID to download it and their albums.
|
||||||
|
|
||||||
|
[-p|--path PATH] Provide to explicitly define download directory.
|
||||||
|
Assumed '.'.
|
||||||
|
|
||||||
|
[-d|--domain DOMAIN] Provide to explicitly define the host where your
|
||||||
|
Funkwhale instance is. Required with -a, -A, and -u.
|
||||||
|
Is not required if you download by a full URL.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
funkblubber https://my.funkwhale/library/tracks/10244/
|
||||||
|
Download album by URL to current folder.
|
||||||
|
|
||||||
|
funkblubber https://my.funkwhale/library/tracks/10244/ -p music
|
||||||
|
Download album by URL to local ./music folder.
|
||||||
|
|
||||||
|
funkblubber -A 152 -d my.funkwhale -p media/music/
|
||||||
|
Download everything by artist with ID 152 from a funkwhale instance
|
||||||
|
with my.funkwhale domain and save it to local ./media/music folder.
|
||||||
|
|
||||||
|
funkblubber --album 1423 -d my.funkwhale
|
||||||
|
Download album with ID 1423 from a funkwhale instance
|
||||||
|
with my.funkwhale domain and save it to current folder.
|
||||||
|
|
||||||
|
''';
|
||||||
|
|
||||||
|
console.info(help);
|
||||||
|
}
|
||||||
|
|
||||||
StageResult _onEntityStage(
|
StageResult _onEntityStage(
|
||||||
final String arg,
|
final String arg,
|
||||||
final ParseResult previousResult,
|
final ParseResult previousResult,
|
||||||
|
@ -193,6 +231,11 @@ StageResult _onNothingStage(
|
||||||
case '--domain':
|
case '--domain':
|
||||||
currentStage = ParsingStage.domain;
|
currentStage = ParsingStage.domain;
|
||||||
break;
|
break;
|
||||||
|
case '-h':
|
||||||
|
case '--help':
|
||||||
|
_onHelpStage();
|
||||||
|
currentStage = ParsingStage.nothing;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
try {
|
try {
|
||||||
final Uri uri = Uri.parse(arg);
|
final Uri uri = Uri.parse(arg);
|
||||||
|
|
Loading…
Reference in New Issue