Fast.cli
An incredible Command Line interface for Flutter. It allows you to create your own CLI without coding a line.
With this CLI, you can create your custom templates and define how your project will start.
The generated directories and files are defined from the outside in, that is, the users define the resources, the CLI generates for you.
You can easily:
- Create
- Use
- Edit
- Share
Do not hesitate to share the plugins created by you with the community, it is very simple.
Features
- Templates generator
- Aplication Scaffold generator
- Snippet generator for Visual Studio Code
- Custom commands
- Standard line commands (Some commands already included in the CLI)
- install (Add a package to the project dependencies)
Install
First of all it is necessary to install the package and configure cache location.
Install this package globally
To do this, you must have the Dart SDK installed and configured
See the guide referring to the installation of packages globally if you have any doubts on how to do it.
Configure cache location
Add the fast cache to your PATH environment variable.
$HOME/.fastcli/bin/
Overview
- Plugin System - Provide the mechanism for you to import a set of templates, resources and custom commands.
- Custom Commands - Commands defined by you to be executed in cmd.
- Scaffold - An initial structural for a project(Start your project with a structure already defined)
- Template - (Code that will be created for your project, as if it were a snippet, but by command line)
Quick Start
Quick use of CLI features.
Install your first plugin
The plugin system is the way in which you can create, use and share your own resources. Think of them as plugins for VS Code, but in this case for a CLI.
To use the CLI it is necessary to install at least one plugin, so install your first plugin with the command below.
Don't worry, just below you will learn how to create your own plugin. For now just install this plugin already created.
Example:
See what the plugin provides
After installing the plugin, an executable is created with his name, so run the command below to test.
Use the "mvc" plugin that was installed directly from the repository.
This command will display the functionalities that the plugin provides.
Use a plugin scaffold
Create a flutter application called "myapp" with the structure defined in the "sample" scaffold of the "mvc" plugin
Example:
Run a plugin custom command
Example:
Use a plugin template
Plugin System
The plugin system is the way in which you can create, use and share your own resources. Think of them as plugins for VS Code, but in this case for a CLI.
This CLI is intended to provide the tool for you to create your own CLI, by default the CLI comes with no resources, that is, it does not have any available plugin, command or scaffold. So to use it is necessary to install at least one plugin.
No VS Code os plugins can provide snippets, themes, icons and other things.
In this CLI the plugins provide:
- Commands
- Scaffolds
- Templates
Structure of a plugin:
scaffolds/ <- Folder to add the scaffols.
templates/ <- Folder to add the templates.
commands.yaml <- File to define custom commands
plugin.yaml <- File to define the name and description of the plugin.
See an example on github clicking here..
Using a plugin
Fisrt instal the plugin. You can install directly from a repository.
When adding a plugin an executable is created with the name of the plugin, so after installing it it is possible to use it by the plugin's own name.
Install:
Use:
Plugin Commands
add
Add a plugin
It is possible to add a plugin directly from a github repository or some local path.
Install directly from a repository.
Install from a local path.
remove
Removes a plugin.
list
Show all installed plugins.
Scaffold
A scaffold is a yaml file where you can define a folder structure and a set of dependencies for a Flutter project.
Instead of creating a blank Flutter project, you can start the project with a folder structure already created and the dependencies configured.
Define a scaffold.yaml
To define your scaffold just follow the example below:
file: scaffold.yaml
Use a scaffold
Add your scaffold.yaml file inside a plugin and then use it.
Example:
Result
When starting your project with the sample scaffold you will have that project as a result.
Template
Templates are files or a set of files that you use to generate code. Generate code as snippests, but by command line.
Define a template
First we define the files that are generated.
In this example, the '@Name' tag will be replaced by the '--name' argument when the file is generated.
file: @name_page.dart
In the same folder as the file above we have the yaml file that defines how the template should be created.
file: template.yaml
Using a template
Run this command so that your template is generated.
example:
Result
You will now have the following file in the path lib/ui/pages/home
Snippets generator
A command to generate snippets for the VC Code based on the template files.
Reuse the code inserted in the template files to generate snippets for Visual Studio Code.
Define your snippets
First we create the template file and template.yaml.
And then set a snippe to be generated.
file: @name_page.dart
file: template.yaml
Generate snippests
Snippests are generated only for the called plugin, so
if I had more snippes installed they will not be generated for them.
Run the command below to generate the snippets.
Example:
Result
It will be possible to use the generated snippet.
Custom Commands
Recording and having to write commands like 'flutter build runner build' it's not a cool thing to do.
,so the custom commands will solve this problem. Write only once and then use them for an alias.
You only need to create a commands.yaml file in your pluginand define your commands.
Define your commands
file: commands.yaml
Running a command
example:
Migrating
v0.3 to v0.4
The commands "config template",'config scaffolds' and 'config commands' have been removed. It is now much easier to configure the CLi and start using it. Just create your plugin and install it.
The scaffolds, templates and commands remain exactly the same, so you will use version 0.4 without making any changes, just add them to your plugin.