An incredible command line interface for Flutter.

Overview

Fast CLI

Fast.cli

Build Status codecov pub package

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)

Migrating from v0.3 to 0.4

Access the guide

Roadmap

  • Improve documentation
    • Mainly the part refers to the installation and configuration.
  • Add a plugin for clean architecture
  • Improve the structure of plugins
  • Add the ability to install plugins from the dart pub.
    • Allowing versioning of plugins
  • Snippet generator for Android Studio

Table Of Contents

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.

$ pub global activate fast

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.

fast plugin add <repository that has a plugin>

Example:

$ fast plugin add git https://github.com/pbissonho/mvc_git_test.git

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.

$ mvc --help

Use a plugin scaffold

<plugin_name> create --name <flutter_projet_name> --scaffold <_scaffold_name>

Create a flutter application called "myapp" with the structure defined in the "sample" scaffold of the "mvc" plugin

Example:

$ mvc create --name myapp --scaffold sample

Run a plugin custom command

mvc run <custom_command_name>

Example:

$ mvc run build

Use a plugin template

mvc <template_name> <template_arg1> <template_arg2> <template_arg3>...
$ mvc page --name myPage 

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 Visual Studio 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.

In Visual Studio Code the 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

First 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:

$ fast plugin add git https://github.com/pbissonho/mvc_git_test.git

Use:

$ mvc --help

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.

$ fast plugin add git https://github.com/pbissonho/mvc_git_test.git

Install from a local path.

$ fast plugin add path home/mypath/

remove

Removes a plugin.

$ fast plugin remove --name <plugin_name>

list

Show all installed plugins.

$ fast plugin list

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.

Also you can add custom files with copy_files: true option and adding files folder inside your scaffold folder. You can use @appName or @AppName tag to replace it with your app name, for example to define imports.

Define a scaffold.yaml

To define your scaffold just follow the example below:

file: scaffold.yaml

# The scaffold name.
name: sample
description: A sample scaffold.
author: Pedro Bissonho <[email protected]>

# The folder structure that will be generated inside the 'lib' folder.
structure:
  - ui:
    - pages
    - shared 
    - themes
  - data:
    - models
    - repositorys
  - blocs
# The folder structure that will be generated inside the 'test' folder.
test_structure:
  - ui:
  - data:
  - fixtures:

# The standard dependencies that the project will have.
# Your project will start with all these dependencies.
# If the version is not informed, the version will be configured as the last version available in Dart Pub.
dependencies: 
  koin: 
  flutter_bloc: 

# The standard dev_dependencies that the project will have.
# If the version is not informed, the version will be configured as the last version available in Dart Pub.
dev_dependencies:
  koin_test:  

Use a scaffold

Add your scaffold.yaml file inside a plugin and then use it.

<plugin_name> create --name <app_name> --scaffold <scaffold_name>

Example:

$ mvc create --name myapp --scaffold mvc1

Result

When starting your project with the sample scaffold you will have that project as a result.

alt text

Example with copy_files option enabled

file: scaffold.yaml

# The scaffold name.
name: clean
description: A scaffold example with files to copy.
author: Alberto Chamorro <[email protected]>

# Copy files option enabled
copy_files: true

# The folder structure that will be generated inside the 'lib' folder.
structure:
  - ui:
  - domain:
    - entities
    - usecases
  - di
  - data:
    - models
    - repositories
    - services

# The folder structure that will be generated inside the 'test' folder.
test_structure:
  - ui:
  - data:
  - domain:

# The standard dependencies that the project will have.
# Your project will start with all these dependencies.
# If the version is not informed, the version will be configured as the last version available in Dart Pub.
dependencies:
  equatable:
  bloc:
  flutter_bloc:

# The standard dev_dependencies that the project will have.
# If the version is not informed, the version will be configured as the last version available in Dart Pub.
dev_dependencies:
  build_runner:

  #Linter
  very_good_analysis:

Then create a folder with name "files" and put your content there.

Scaffold with files

All tags '@AppName' and '@appName' would be replaced with your application name.

Add your scaffold.yaml file inside a plugin and then use it.

<plugin_name> create --name <app_name> --scaffold <scaffold_name>

Example:

$ fast_files_sample create --name myapp --scaffold clean

You have a repository with this example here

Template

Templates are files or a set of files that you use to generate code. Generate code as snippets, 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

import 'package:flutter/material.dart';

class @NamePage extends StatefulWidget {
  @override
  _@NamePageState createState() => _@NamePageState();
}

class _@NamePageState extends State<@NamePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Text("Hello"),
      ),
    );
  }
}

In the same folder as the file above we have the yaml file that defines how the template should be created.

file: template.yaml

#Yaml file for configuring the template.
#The template name
name: page
#The template description
description: Create_flutter_page.
#Path where files should be sent
to: lib/ui/pages/@name
#Arguments to be passed when executing this template
# You can define as many arguments as you want.
args:
  - name
# - other1
# - other2
# - other3

Using a template

Run this command so that your template is generated.

<plugin_name> <template_name>  <templates_arg1, templates_arg2, templates_arg3...>

example:

$ mvc page --name home

Result

You will now have the following file in the path lib/ui/pages/home

import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Text("Hello"),
      ),
    );
  }
}

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

import 'package:flutter/material.dart';

class @NamePage extends StatefulWidget {
  @override
  _@NamePageState createState() => _@NamePageState();
}

class _@NamePageState extends State<@NamePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Text("Hello"),
      ),
    );
  }
}

file: template.yaml

name: page
description: Create_flutter_page.
to: lib/ui/pages/@name
# You can define as many arguments as you want.
args:
  - name

# Set up a list of snippests.
snippets:
  # The file containing the snippet code to be generated
  # Reuse the code inserted in one of the template files to generate a VC Code snippets.
  - file: '@name_page.dart'
    prefix: page
    #File lines that will not be included in the snippet.
    excluded:
      - 0
      - 1
# It is possible to create snippests for each template file.
# - file: '@name_other1.dart'
#    prefix: other1
#    excluded:
#      - 0
# - file: '@name_other2.dart'
#    prefix: other2
#    excluded:
#      - 0   

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.

<plugin_name> snippets

Example:

$ mvc snippets

Result

It will be possible to use the generated snippet.

alt-text

Custom Commands

Recording and having to write commands like 'flutter pub run build_runner build --delete-conflicting-outputs' 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 plugin and define your commands.

Define your commands

file: commands.yaml

commands:
  build: flutter pub run build_runner build
  buildx: flutter pub run build_runner build --delete-conflicting-outputs
  watch: flutter pub run build_runner watch
  push: git push origin master

Running a command

<plugin_name> run <command_name>

example:

$ mvc run build

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.

License

license.

You might also like...

Listen to remote Flutter GTK application instances' command-line arguments and file open requests.

gtk_application This package allows the primary Flutter GTK application instance to listen to remote application instances' command-line arguments and

Dec 15, 2022

A command-line application provide an load optimization solution for flutter web

A command-line application provide an load optimization solution for flutter web

一个命令行工具,针对flutter web加载慢和缓存问题提供了一套解决方案。 功能 通过大文件分片和资源文件cdn化方式,优化flutter web页面加载慢问题。 通过资源文件hash化,解决浏览器强缓存导致功能无法更新问题。 开始 局部安装 dev_dependencies: flutte

Dec 29, 2022

changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart 🎯 changelog.dart: a collection of tools to manages in a fashion way a repository as maintainer. 🎯 Project Homepage Table of Content I

Dec 18, 2022

This is a simple Gantt chart generator written as Dart command line tool.

This is a simple Gantt chart generator written as Dart command line tool.

Gantt Chart Generator This is a simple Gantt chart generator written as Dart command line tool. Currently the tool generates an HTML/CSS Gantt chart.

Apr 26, 2022

OrderFoody - A template with command buttons in horizontal scrolling list

OrderFoody - A template with command buttons in horizontal scrolling list

order_coffee In this project you create a template with command buttons in horiz

Jun 22, 2022

Mnt-ng-flutter - The Mnt NG app interface written in flutter

Mnt-ng-flutter - The Mnt NG app interface written in flutter

Mnt Ng Flutter Mnt NG application interface in flutter About This project is meant to be only the Mnt Ng interface, all the data exhibited here is fak

Dec 23, 2019

A Flutter widget that forces the device rotates into the set of orientations the application interface can be displayed in.

A Flutter widget that forces the device rotates into the set of orientations the application interface can be displayed in. Features Force device keep

Nov 30, 2021

Firebase dart common interface and implementation for Browser, VM, node and flutter

firebase.dart Firebase dart common interface and implementation for Browser, VM, node and flutter Firebase Initialization Usage in browser import 'pac

Nov 28, 2021

This is a set of small projects focused solely on the development of the graphical interface with Flutter

This is a set of small projects focused solely on the development of the graphical interface with Flutter

My Flutter Projects Flutter apps with cool design and animations Social Media Youtube Facebook Twitter Getting Started This project is a starting poin

Dec 19, 2022
Comments
  • New feature: copy scaffold files

    New feature: copy scaffold files

    I have added a new action when you are creating the scaffolds.

    Now you can add a new option in your scaffold.yaml file copy_files: true and add a folder called "files" in the scaffold folder with the project files.

    This new option in your config file is optional so you don't have problems with old configurations.

    opened by achamorro-dev 1
  • Fixed two errors

    Fixed two errors

    I have added two fixes:

    • CLI doesn't stop execution if "flutter create" returns an error, for example if you try to create an app with "-" character in the name.
    • lib/main.dart and test/widget_test.dart files are being removed and you need to create them manually.
    opened by achamorro-dev 0
Releases(v0.5.0)
Owner
Pedro Bissonho
Flutter Developer
Pedro Bissonho
Command Line Interface (CLI) for Lucifer

Lucy Command Line Interface (CLI) for Lucifer. Installation Activate command line from your terminal with this command. pub global activate lucy Usage

Salman S 1 Dec 16, 2021
A Nerolab Command Line Interface for Dart created by Nerolab

Nerolab CLI Nerolab Command Line Interface for Dart. Special thanks to GroovinChip with groovin_cli and very_good_cli. Installing dart pub global acti

Nerolab 1 Jan 19, 2022
☄ Anime/Manga command-line interface backed up by Tenka.

Yukimi ☄ Anime/Manga command-line interface backed up by Tenka. By using this project, you agree to the usage policy. Installation Pre-built binaries

Yukino Org 28 Jan 6, 2023
Interactive command line interface Couchbase Lite REPL utility built with the Dart

Couchbase Lite Dart CLI Interactive command line interface Couchbase Lite REPL utility built with the Dart programming language. This code uses the cb

Pieter Greyling 2 Jul 20, 2022
Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line.

flutter_distributor Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line. The flutter_distributor source

LeanFlutter 416 Dec 24, 2022
Screenshots - A command line utility and package for capturing screenshots for Flutter

A screenshot image with overlaid status bar placed in a device frame. For an example of images generated with Screenshots on a live app in both stores

Maurice McCabe 258 Nov 22, 2022
shared_versions is a command line tool that allow share the versions for multiple packages in Flutter

shared_versions shared_versions is a CLI tool that allow share the versions for multiple packages in Flutter. Usage shared_versions will match the pac

Littlegnal 6 Sep 20, 2022
This is a command-line app written on dart language for flutter applications that will help you to generate some boilerplate code

dart-generator Manual installation: 1- generate a platform executable from code dart compile exe main.dart -o generator this will generate a new gene

One Studio 11 Oct 26, 2022
Icons Launcher - A command-line tool that simplifies the task of updating your Flutter app's launcher icon.

Icons Launcher - A command-line tool that simplifies the task of updating your Flutter app's launcher icon. Full flexibility allows you to only update the launcher icon for specific platforms as needed.

Mrr Hak 48 Nov 17, 2022
Scaff is a simple command-line utility for generating Dart and Flutter components from template files.

Introduction Scaffold Generator for Dart and Flutter. scaff is a simple command-line utility for generating Dart and Flutter components from template

Ganesh Rathinavel Medayil 29 Jul 17, 2022