feat: Add -p flag for explicit path
This commit is contained in:
parent
23dcc4b74a
commit
d8ddc8001a
|
@ -11,5 +11,8 @@ void main(final List<String> arguments) async {
|
|||
return;
|
||||
}
|
||||
|
||||
await funkblubber.download(object: result.object!);
|
||||
await funkblubber.download(
|
||||
object: result.object!,
|
||||
path: result.localPath ?? '.',
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:funkblubber/console.dart' as console;
|
|||
|
||||
Future<void> download({
|
||||
required final FunkObject object,
|
||||
final String path = '.',
|
||||
required final String path,
|
||||
}) async {
|
||||
console.info('Downloading');
|
||||
switch (object.kind) {
|
||||
|
|
|
@ -76,6 +76,12 @@ ParseResult extract(final List<String> args) {
|
|||
result = stageResult.result;
|
||||
break;
|
||||
|
||||
case ParsingStage.path:
|
||||
final stageResult = _onPathStage(arg, result, currentStage);
|
||||
currentStage = stageResult.stage;
|
||||
result = stageResult.result;
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error('not implemented yet');
|
||||
break;
|
||||
|
@ -137,6 +143,28 @@ StageResult _onDomainStage(
|
|||
return StageResult(result: result, stage: currentStage);
|
||||
}
|
||||
|
||||
String _cutTrailingDash(final String path) =>
|
||||
path.endsWith('/') ? path.substring(0, path.length - 1) : path;
|
||||
|
||||
StageResult _onPathStage(
|
||||
final String arg,
|
||||
final ParseResult previousResult,
|
||||
final ParsingStage previousStage,
|
||||
) {
|
||||
ParsingStage currentStage = previousStage;
|
||||
ParseResult result = previousResult;
|
||||
|
||||
currentStage = ParsingStage.nothing;
|
||||
result = ParseResult(
|
||||
localPath: _cutTrailingDash(arg),
|
||||
action: previousResult.action,
|
||||
success: true,
|
||||
object: previousResult.object,
|
||||
);
|
||||
|
||||
return StageResult(result: result, stage: currentStage);
|
||||
}
|
||||
|
||||
StageResult _onNothingStage(
|
||||
final String arg,
|
||||
final ParseResult previousResult,
|
||||
|
|
Loading…
Reference in New Issue