mason logo

en es

Codescript CLI is a tool designed to streamline the process of generating Flutter project components. It provides simple commands to generate various architecture components such as views, viewmodels, repositories, bindings, and use cases, or even set up a full architecture in a matter of seconds. This enhances consistency and speeds up development in Flutter projects.

Codescript

Features

  • Generate individual components: Easily create views, viewmodels, repositories, bindings, and use cases.
  • Full architecture generation: Generate a complete architecture setup with one command.
  • Fast and efficient: Automate repetitive tasks, saving time and effort.

Usage

Once installed, you can use the codescript commands to generate components directly from your terminal.

Commands

  • Generate a View:

    codescript view <view_name>
    
  • Generate a ViewModel:

    codescript viewmodel <viewmodel_name>
    
  • Generate a Repository:

    codescript repository <repository_name>
    
  • Generate a Binding:

    codescript binding <binding_name>
    
  • Generate a Use Case:

    codescript usecase <usecase_name>
    
  • Generate a Full Architecture (includes view, viewmodel, repository, binding, and use case):

    codescript full <resource_name>
    
  • Generate a Route :

    codescript route <resource_name>
    
  • Generate a Service :

    codescript service <resource_name>
    

Example

To generate a full architecture setup for a User resource, run:

codescript full user

This command will be generate:

lib/
└── app/
     ├── /ui
     │   └── /views
        │   └── user_view.dart
        │   └── user_viewmodel.dart
└── data/
     ├── repositories/
     │   └── user_repository.dart
     │   └── user_repository_implementation.dart
└── di/
     ├── user_binding.dart
└── domain/
        └── usecases/
            └── user_usecase.dart

Customize Output Paths

By default, the generated components follow a specific folder structure. You can customize the paths for each component by modifying the codescript.yaml configuration file located at the root of your project. Here’s an example configuration:

paths:
  view: lib/ui/views
  viewmodel: lib/ui/viewmodels
  repository: lib/data/repositories
  binding: lib/di
  route: lib/src/ui/
  service: lib/common/services
  usecase: lib/domain/usecases

In this example, the paths for each component have been customized. You can modify the paths to suit your project structure. The next time you generate a component, it will be placed in the specified directory.

Libraries

easy_code
Easy code library This library is a collection of useful functions that can be used to make coding easier.