pipe_cli 1.0.2
pipe_cli: ^1.0.2 copied to clipboard
Pipeline for everything.
Pipe CLI #
Why should I use it? #
Motivations #
Features #
Create CLI (Command Line Interface) #
Create your own CLI without create a new project, using pre-fabs commands.
Installation #
dart pub global activate pipe_cli
usage #
- Create a pipe.md file, write your CLI command using yaml
- Run your CLI command
pipe <your_created_cli>
Pipe.md #
Create a markdown file named pipe.md then write your first command.
**`name_of_script`**
```yaml
gen_usecase:
name: usecase
abbr: u
description: 'Creates an usecase in a custom template'
```
Declaration of flags and options [Work In Progress].
```yaml
args:
repository:
help: 'Create repository file'
abbr: r
negatable: false
service:
help: 'Create service file'
abbr: s
negatable: false
no-test:
help: 'Avoid test files creation'
abbr: n
negatable: false
```
The command receive a pattern, extracts of this pattern
two arguments `feature` and `name`, then creates a usecase named `**name**_usecase.dart` in
`lib/**feature**/domain/usecases/` path from templates `interface_usecase` and `usecase`.
```yaml
execute:
- install:
- get_it
- capture:
text: '{{rest}}'
regex: '(?<feature>[A-z]*)@(?<name>[A-z]*)'
- file_name: '{{name}}_usecase'
- file_path: 'lib/features/{{feature}}/domain/usecase/{{file_name}}.dart'
- build_usecase: '{{interface_usecase}}{{\n}}{{usecase}}'
- created_by: 'andré_ervilha'
- generate:
template: '{{build_usecase}}'
path: '{{file_path}}'
```
# Templates
Creates a new line
**`\n`**
```dart
```
Template of an interface for Usecases
**`interface_usecase`**
```dart
// Created by {{created_by|pascalCase}}, {{created_by|snackCase}}
abstract class I{{file_name|pascalCase}} {
Future<void> call();
}
```
Template of an implementation of Usecase using interface
**`usecase`**
```dart
class {{file_name|pascalCase}} extends I{{file_name|pascalCase}} {
@override
Future<void> call() async {
throw UnimplementedError();
}
}
```
Detailing #
- Name of your script
You must declare the name of yaml script at least once, on first declaration.
````markdown
**`name_of_script`**
````
- Script declaration named
gen_usecase, where created a CLI command namedusecasewith abbrevuand descriptionCreates an usecase in a custom template.
Must be at next line after name.
**`name_of_script`**
```yaml
usecase:
name: usecase
abbr: u
description: 'Creates an usecase in a custom template'
```
-
Documentation of your script.
Declaration of flags and options [Work In Progress]. -
Continuation of
gen_usecasescript, declaring flags to be used on your CLI commandusecase.```yaml args: repository: help: 'Create repository file' abbr: r negatable: false service: help: 'Create service file' abbr: s negatable: false no-test: help: 'Avoid test files creation' abbr: n negatable: false ``` -
Execution steps declaration
Note that there are Objects and Values, the objects are interpreted as a Command and the Values as a Variable.
```yaml execute: - install: - get_it - capture: text: '{{rest}}' regex: '(?<feature>[A-z]*)@(?<name>[A-z]*)' - file_name: '{{name}}_usecase' - file_path: 'lib/features/{{feature}}/domain/usecase/{{file_name}}.dart' - build_usecase: '{{interface_usecase}}{{\n}}{{usecase}}' - created_by: 'andré_ervilha' - generate: template: '{{build_usecase}}' path: '{{file_path}}' ``` -
Creates a dart template
**`interface_usecase`** ```dart // Created by {{created_by|pascalCase}}, {{created_by|snackCase}} abstract class I{{file_name|pascalCase}} { Future<void> call(); } ```