A simple scaffolding framework for Dart CLI tools. This makes it easier to get projects off the ground. It also depends on args and console, so those packages are available for your usage.


project_gen has a simple, callback-based structure, and ultimately just provides abstractions to create files within a project directory.

Placing your code in callbacks will ensure files are created in order. Directories are created first, and then files.

import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:project_gen/project_gen.dart';

class InitCommand extends Command {
    String get name => 'init';

    String get description => 'Initializes a new project.';

    run() async {
        // New project in the current dir
        var project = new Project('<project-name>');'web', (web) async {
            // Clone a repo into a directory.
            // By default, the .git dir will be deleted.
            await web.clone('git://path/to/repo');
        });'views', (views) async {
            views.file('index.jade', (index) async {
                await index.copyResource('package:example/res/views/index.jade');
                await index.copyFile(new File('/path/to/file'));
  'admin', (admin) async {
                // Without a callback
                var foo = admin.file('foo.txt');

                // Access underlying `dart:io` File or Directory
                await someStream().pipe(;

        // Run all generators and actions, and also run `pub get`
        await project.generate();

        // Pre-build assets
        await, ['tool/build.dart']);

Maintaining Projects

The API's in project_gen only create directories/files if they do not exist, so they can be used to modify existing projects.

You generally will not need to use callbacks for existing projects.

import 'package:project_gen/project_gen.dart';

main() async {
    // Load project out of current dir
    var project = await Project.load();

    // Create file if it doesn't exist, otherwise just open the existing one
    var readme = project.file('');