bpriver_chain 0.7.3
bpriver_chain: ^0.7.3 copied to clipboard
Implementation of chain language. Available as cui, argument parser or inter-appliation communication.
Chain Language
Chain is serial data description language.
Use #
- cui
- argument parser
- inter-application communication
- serialize(Recursive nesting is possible)
Syntax #
For example, tiger 's cui is chain language.
tiger run --taskLocation 'abc' --taskName 'tiger_sample.yaml'
run
is head.
--taskLocation 'abc'
and --taskName 'tiger_sample.yaml'
is option.
There is no example, -log
is flag.
Chain contains only Head, Option, and Flag.
Each name must be unique #
Head name, option name, and flag name must not be duplicate.
Head #
- head position is the beginning.
- head prefix is no hypen.
- head is not empty.
- head quantity must be 1.
Option #
- option position is free.
- option prefix is double-hypen.
- option is not empty.
- option quantity is 0 or more.
- option value quantity is 0 or more.
- In the above example,
'abc'
and'tiger_sample.yaml'
is option value.
- In the above example,
- option value position is right behind option or right behind option value.
- you can make a List by placing option value in a row.
- example,
--something 'a' 'b' 'c'
- if the option value prefix is hypen, an escape is required.
- escape sequence is
\
. - example,
--something '\-\-great data'
- escape sequence is
- option value is available empty.
- example,
--something '' 'b' 'c'
- example,
Flag #
- flag position is free.
- flag prefix is single-hypen.
- flag is not empty.
- flag quantity is 0 or more.
Delimiter #
- delimiter is space only.
- space quantity is 1 or more.
Include white space #
if you want to include white space in serial source, Please circle it with single or double quotation.
example: --something 'hello world'
Include quotation #
if you want to include single quotation in serial source, Please circle it with double quotation.
example: --something "abc'def'ghi"
if you want to include double quotation in serial source, Please circle it with single quotation.
example: --something 'abc"def"ghi'
Other #
Triple-hypen or more prefix
Valid as head or option value.
But, Not recommended.
Pass value that starts with a hyphen to option value
Impossible.
There is no shorthand for head, option, and flag
There is only one way to specify.
Please depend on bpriver_origin library #
When extracting values from the chain, we use the Result type.
dependencies:
bpriver_origin: ^2.1.0
Result type is available.
import 'package:bpriver_origin/logger_result.dart';
Data serialize. #
This can be achieved by storing the chain string as the option value. For Example,
A --a 'B --b \'C --c \\'something value\\'\''
--a
has 'B --b \'C --c \\'something value\\'\''
.
--b
has \'C --c \\'something value\\'\'
.
--c
has \\'something value\\'
.
The deeper the nesting, the more escape sequences will accumulate.
This has some drawbacks:
- Readabilityis not good.
- The danger of data becoming too large.
- Because escape sequences accumulate
It is also possible to store other formats. For example json,
A --a '{ "name": "arakawa", "job": "unemployed" }'
The specific code is here. test\nested_chain\nested_chain_test.dart
.
Code example #
The example code is in the example folder.