Skip to content

Commit fb10838

Browse files
committed
app command now shows version and description
1 parent de8d258 commit fb10838

File tree

6 files changed

+91
-7
lines changed

6 files changed

+91
-7
lines changed

bin/main.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/// "firmwareVersion": "01.51",
1616
/// ...
1717
import 'dart:io';
18+
import 'package:apitest/cli/app_cli.dart';
1819
import 'package:args/args.dart';
1920
import 'package:yaml/yaml.dart';
2021
import 'package:apitest/cli/auto_bracket_cli.dart';
@@ -85,7 +86,8 @@ void main(List<String> args) async {
8586
..addCommand(SetMySettingCli())
8687
..addCommand(ShutterVolumeCli())
8788
..addCommand(DownloadCli())
88-
..addCommand(StopCaptureCli());
89+
..addCommand(StopCaptureCli())
90+
..addCommand(AppCli());
8991

9092
await runner.run(args).catchError((error) {
9193
if (error is! UsageException) throw error;

lib/cli/00_pubspec_contents.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var pubspecContents = '''
2+
name: apitest
3+
version: 0.1.1-alpha
4+
description: >-
5+
RICOH THETA WebAPI test implementation with Dart by Oppkey and the community.
6+
Based on RICOH THETA API v2.1
7+
Direct questions to the community.theta360.guide.
8+
The WebAPI is usually used with mobile apps. This tool is a command line
9+
interface to a Dart library that can also be used with Flutter for iOS
10+
and Android. This command line tool can be put into bash scripts.
11+
dependencies:
12+
http: ^0.12.2
13+
args: ^1.6.0
14+
theta:
15+
git:
16+
url: https://github.com/codetricity/theta
17+
ref: main
18+
# change the path below to the path above for production use
19+
# path: ../theta
20+
dcli: ^0.41.0
21+
yaml: ^2.2.1
22+
path: ^1.7.0
23+
24+
environment:
25+
sdk: '>=2.10.0 <3.0.0'
26+
27+
dev_dependencies:
28+
pedantic: ^1.0.0
29+
30+
repository: https://github.com/theta360developers/webapi
31+
homepage: https://theta360developers.github.io/webapi/
32+
''';

lib/cli/app_cli.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:args/command_runner.dart';
22
import 'dart:io';
33
import 'package:yaml/yaml.dart';
4-
import 'package:path/path.dart' as p;
4+
import '00_pubspec_contents.dart';
55

66
class AppCli extends Command {
77
@override
@@ -21,17 +21,15 @@ class AppCli extends Command {
2121

2222
@override
2323
void run() async {
24-
var pathToYaml =
25-
p.join(p.dirname(Platform.script.toFilePath()), '../pubspec.yaml');
26-
var file = await File(pathToYaml);
27-
var yamlString = file.readAsStringSync();
28-
var conf = loadYaml(yamlString);
24+
var conf = loadYaml(pubspecContents);
2925
if (argResults.arguments.isEmpty) {
3026
printUsage();
3127
} else if (argResults.wasParsed('version')) {
3228
print(conf['version']);
3329
} else if (argResults.wasParsed('description')) {
30+
print('\n');
3431
print(conf['description']);
32+
print('\n');
3533
} else if (argResults.wasParsed('repository')) {
3634
print(conf['repository']);
3735
} else if (argResults.wasParsed('homepage')) {

lib/cli/app_does_not_work_cli.dart

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import 'package:args/command_runner.dart';
2+
import 'dart:io';
3+
import 'package:yaml/yaml.dart';
4+
import 'package:path/path.dart' as p;
5+
6+
// this does not work as the pubspec.yaml file is not distributed
7+
// with the theta.exe binary
8+
9+
class AppCli extends Command {
10+
@override
11+
final name = 'app';
12+
13+
@override
14+
final description = 'information on this app. --version shows version';
15+
16+
AppCli() {
17+
argParser
18+
..addFlag('version',
19+
help: 'version information for this app', negatable: false)
20+
..addFlag('description', help: 'app description', negatable: false)
21+
..addFlag('repository', help: 'url of GitHub repo', negatable: false)
22+
..addFlag('homepage', help: 'blog for this tool', negatable: false);
23+
}
24+
25+
@override
26+
void run() async {
27+
var pathToYaml =
28+
p.join(p.dirname(Platform.script.toFilePath()), '../pubspec.yaml');
29+
var file = await File(pathToYaml);
30+
var yamlString = file.readAsStringSync();
31+
var conf = loadYaml(yamlString);
32+
if (argResults.arguments.isEmpty) {
33+
printUsage();
34+
} else if (argResults.wasParsed('version')) {
35+
print(conf['version']);
36+
} else if (argResults.wasParsed('description')) {
37+
print(conf['description']);
38+
} else if (argResults.wasParsed('repository')) {
39+
print(conf['repository']);
40+
} else if (argResults.wasParsed('homepage')) {
41+
print(conf['homepage']);
42+
} else {
43+
printUsage();
44+
}
45+
46+
exit(0);
47+
}
48+
}

pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: apitest
2+
# IMPORTANT: copy the contents of this file into ./lib/cli/00_pubspec_contents.dart
3+
# when the version or description is changed.
24
version: 0.1.1-alpha
5+
# IMPORTANT: copy the contents of this file into ./lib/cli/00_pubspec_contents.dart
6+
# when the version or description is changed.
37
description: >-
48
RICOH THETA WebAPI test implementation with Dart by Oppkey and the community.
59
Based on RICOH THETA API v2.1

script_examples/theta.exe

226 KB
Binary file not shown.

0 commit comments

Comments
 (0)