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;
|
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({
|
Future<void> download({
|
||||||
required final FunkObject object,
|
required final FunkObject object,
|
||||||
final String path = '.',
|
required final String path,
|
||||||
}) async {
|
}) async {
|
||||||
console.info('Downloading');
|
console.info('Downloading');
|
||||||
switch (object.kind) {
|
switch (object.kind) {
|
||||||
|
|
|
@ -76,6 +76,12 @@ ParseResult extract(final List<String> args) {
|
||||||
result = stageResult.result;
|
result = stageResult.result;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ParsingStage.path:
|
||||||
|
final stageResult = _onPathStage(arg, result, currentStage);
|
||||||
|
currentStage = stageResult.stage;
|
||||||
|
result = stageResult.result;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.error('not implemented yet');
|
console.error('not implemented yet');
|
||||||
break;
|
break;
|
||||||
|
@ -137,6 +143,28 @@ StageResult _onDomainStage(
|
||||||
return StageResult(result: result, stage: currentStage);
|
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(
|
StageResult _onNothingStage(
|
||||||
final String arg,
|
final String arg,
|
||||||
final ParseResult previousResult,
|
final ParseResult previousResult,
|
||||||
|
|
Loading…
Reference in New Issue