Skip to content

An open-source cross-platform alternative to AirDrop

feat(cli): add basic help information

Tien Do Nam2457acd8a741
diff --git a/cli/lib/main.dart b/cli/lib/main.dart
index d721de6e..c3dd1890 100644
--- a/cli/lib/main.dart
+++ b/cli/lib/main.dart
@@ -1,3 +1,39 @@
-void main(List<String> arguments) {
- print('Hello world!');
+import 'dart:io';
+
+import 'package:args/args.dart';
+import 'package:path/path.dart' as path;
+
+Future<void> main(List<String> arguments) async {
+ final parser = ArgParser();
+
+ parser.addFlag('help', abbr: 'h', negatable: false, help: 'Prints usage information', defaultsTo: false);
+ parser.addFlag('receive', abbr: 'r', negatable: false, help: 'Start a server to receive files', defaultsTo: false);
+ parser.addFlag('send', abbr: 's', negatable: false, help: 'Setups a client to send files', defaultsTo: false);
+
+ final results = parser.parse(arguments);
+
+ if (results['help']) {
+ _printUsage(parser);
+ return;
+ }
+
+ final receive = results['receive'] as bool;
+ final send = results['send'] as bool;
+
+ if (receive) {
+ print('Starting server...');
+ } else if (send) {
+ print('Setting up client...');
+ } else {
+ _printUsage(parser);
+ }
+}
+
+void _printUsage(ArgParser parser) {
+ print('The LocalSend CLI to send and receive files locally.');
+ print('');
+ print('Usage: ${path.basename(Platform.executable)} [options]');
+ print('');
+ print('Options:');
+ print(parser.usage);
}
diff --git a/cli/pubspec.lock b/cli/pubspec.lock
index a9fb0116..2a0ba1dc 100644
--- a/cli/pubspec.lock
+++ b/cli/pubspec.lock
@@ -18,7 +18,7 @@ packages:
source: hosted
version: "6.2.0"
args:
- dependency: transitive
+ dependency: "direct main"
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
@@ -164,10 +164,10 @@ packages:
dependency: transitive
description:
name: meta
- sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
+ sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
- version: "1.10.0"
+ version: "1.12.0"
mime:
dependency: transitive
description:
@@ -193,13 +193,13 @@ packages:
source: hosted
version: "2.1.0"
path:
- dependency: transitive
+ dependency: "direct main"
description:
name: path
- sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
+ sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
- version: "1.8.3"
+ version: "1.9.0"
pool:
dependency: transitive
description:
diff --git a/cli/pubspec.yaml b/cli/pubspec.yaml
index e2b5c949..15654324 100644
--- a/cli/pubspec.yaml
+++ b/cli/pubspec.yaml
@@ -7,8 +7,10 @@ environment:
sdk: ^3.1.1
dependencies:
+ args: 2.4.2
common:
path: ../common
+ path: 1.9.0
dev_dependencies:
lints: ^2.0.0