Add initial files
This commit is contained in:
parent
203069260d
commit
12f4e63ea9
10 changed files with 215 additions and 0 deletions
3
dart/.gitignore
vendored
Normal file
3
dart/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# https://dart.dev/guides/libraries/private-files
|
||||
# Created by `dart pub`
|
||||
.dart_tool/
|
3
dart/CHANGELOG.md
Normal file
3
dart/CHANGELOG.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
## 1.0.0
|
||||
|
||||
- Initial version.
|
1
dart/README.md
Normal file
1
dart/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
A sample command-line application providing basic argument parsing with an entrypoint in `bin/`.
|
30
dart/analysis_options.yaml
Normal file
30
dart/analysis_options.yaml
Normal file
|
@ -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
|
61
dart/bin/dart.dart
Normal file
61
dart/bin/dart.dart
Normal file
|
@ -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 dart.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('dart 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);
|
||||
}
|
||||
}
|
18
dart/pubspec.yaml
Normal file
18
dart/pubspec.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
name: dart
|
||||
description: A sample command-line application with basic argument parsing.
|
||||
version: 0.0.1
|
||||
# repository: https://github.com/my_org/my_repo
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.1
|
||||
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
args: ^2.4.2
|
||||
libac_dart:
|
||||
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
||||
version: 1.2.82924+1846
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^4.0.0
|
||||
test: ^1.24.0
|
Loading…
Add table
Add a link
Reference in a new issue