Skip to content

Commit

Permalink
add rfw_tools, need to move rfw2txt, txt2rfw to single tools package
Browse files Browse the repository at this point in the history
  • Loading branch information
ebwood committed Mar 14, 2024
1 parent a1f64bf commit 4a615c8
Show file tree
Hide file tree
Showing 12 changed files with 514 additions and 0 deletions.
3 changes: 3 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ packages:
- packages/rfw2txt
- packages/widget2rfw
- packages/rfw_builder
- packages/rfw_tools

scripts:
add_sort:
exec: dart pub add --dev import_sorter
push:
run: melos run analyze && git push
import_sort:
Expand Down
3 changes: 3 additions & 0 deletions packages/rfw_tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
3 changes: 3 additions & 0 deletions packages/rfw_tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
1 change: 1 addition & 0 deletions packages/rfw_tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A sample command-line application providing basic argument parsing with an entrypoint in `bin/`.
30 changes: 30 additions & 0 deletions packages/rfw_tools/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
3 changes: 3 additions & 0 deletions packages/rfw_tools/bin/rfw2txt.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void main() {
print('rfw2txt cli');
}
61 changes: 61 additions & 0 deletions packages/rfw_tools/bin/rfw_tools.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:args/args.dart';

const String version = '0.0.1';

ArgParser buildParser() {
return ArgParser()
..addFlag(
'help',
abbr: 'h',
negatable: false,
help: 'Print this usage information.',
)
..addFlag(
'verbose',
abbr: 'v',
negatable: false,
help: 'Show additional command output.',
)
..addFlag(
'version',
negatable: false,
help: 'Print the tool version.',
);
}

void printUsage(ArgParser argParser) {
print('Usage: dart rfw_tools.dart <flags> [arguments]');
print(argParser.usage);
}

void main(List<String> arguments) {
final ArgParser argParser = buildParser();
try {
final ArgResults results = argParser.parse(arguments);
bool verbose = false;

// Process the parsed arguments.
if (results.wasParsed('help')) {
printUsage(argParser);
return;
}
if (results.wasParsed('version')) {
print('rfw_tools version: $version');
return;
}
if (results.wasParsed('verbose')) {
verbose = true;
}

// Act on the arguments provided.
print('Positional arguments: ${results.rest}');
if (verbose) {
print('[VERBOSE] All arguments: ${results.arguments}');
}
} on FormatException catch (e) {
// Print usage information if an invalid argument was provided.
print(e.message);
print('');
printUsage(argParser);
}
}
3 changes: 3 additions & 0 deletions packages/rfw_tools/bin/txt2rfw.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void main() {
print('txt2rfw cli');
}
Empty file.
Loading

0 comments on commit 4a615c8

Please sign in to comment.