feat: Implement --help

This commit is contained in:
NaiJi ✨ 2023-02-02 01:30:06 +04:00
parent d8ddc8001a
commit f9beb23d44
2 changed files with 44 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import 'package:funkblubber/parsing/parser.dart' as parser;
void main(final List<String> arguments) async {
final result = parser.extract(arguments);
if (!result.success) {
console.error("'funkblubber --help 'for more");
console.error("'funkblubber --help' for more");
return;
}

View File

@ -91,6 +91,44 @@ ParseResult extract(final List<String> args) {
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(
final String arg,
final ParseResult previousResult,
@ -193,6 +231,11 @@ StageResult _onNothingStage(
case '--domain':
currentStage = ParsingStage.domain;
break;
case '-h':
case '--help':
_onHelpStage();
currentStage = ParsingStage.nothing;
break;
default:
try {
final Uri uri = Uri.parse(arg);