cli_core 0.0.2-dev.4 copy "cli_core: ^0.0.2-dev.4" to clipboard
cli_core: ^0.0.2-dev.4 copied to clipboard

A shared utility package for CLI operations in Flutter Forge packages, providing utilities for CLI commands, Flutter project management, Melos workspace management, and file operations.

Nonstop Logo

NonStop

Digital Product Development Experts for Startups & Enterprises

About | Website

cli_core #

cli_core

A shared utility package for CLI operations in Flutter Forge packages, providing core functionality for CLI commands, Flutter project management, and Melos workspace operations.

Table of Contents #

Overview #

CLI Core provides the foundational building blocks for creating CLI tools in the Flutter Forge ecosystem. It abstracts common CLI operations, provides progress tracking, and includes utilities for Flutter project management and Melos workspace operations.

Features #

  • 🚀 Base CLI command infrastructure with progress tracking
  • 📱 Flutter project creation and management utilities
  • 📦 Melos workspace management utilities
  • 🔧 File system utilities for common operations

Usage #

Command Infrastructure #

Create custom CLI commands by extending the base command classes:

import 'package:cli_core/cli_core.dart';

class MyCommand extends CliCommand {
  @override
  Future<void> run(HookContext context) async {
    await trackOperation(
      context,
      startMessage: 'Starting operation',
      endMessage: 'Operation completed',
      operation: () => yourOperation(),
    );
  }
}
copied to clipboard

Flutter Commands #

Manage Flutter projects with built-in utilities:

class MyFlutterCommand extends BaseFlutterCommand {
  Future<void> execute(HookContext context) async {
    await createFlutterProject(
      context: context,
      name: 'my_app',
      description: 'My Flutter application',
      outputPath: 'path/to/output',
    );
  }
}
copied to clipboard

Melos Commands #

Handle Melos workspace operations:

class MyMelosCommand extends BaseMelosCommand {
  Future<void> execute(HookContext context) async {
    await bootstrap(
      context: context,
      workspacePath: 'path/to/workspace',
    );
  }
}
copied to clipboard

File Operations #

Perform common file system operations:

// Using file utilities
Future<void> fileOperations() async {
  // Create directories
  await FileUtils.ensureDirectory('path/to/dir');
  
  // Write YAML files
  await FileUtils.writeYamlFile('config.yaml', 'content: value');
  
  // Read YAML files
  final content = await FileUtils.readYamlFile('config.yaml');
  
  // Copy files
  await FileUtils.copyFile('source.txt', 'dest.txt');
  
  // Check for mono-repo
  final isMonoRepo = await FileUtils.isMonoRepo();
}
copied to clipboard

Logger Extension #

The LoggerX extension on the Logger class provides additional utility methods for logging in CLI applications.

Methods

  • void created(String message): Logs a message with a specific style indicating creation.
  • void wrap(String? text, {required void Function(String?) print, int? length}): Wraps the provided text to fit within the terminal width, taking into account ANSI escape sequences for styling.

Example

import 'package:cli_core/cli_core.dart';
import 'package:mason_logger/mason_logger.dart';

void main() {
  final logger = Logger();
  logger.created('Project created successfully');
  logger.wrap('This is a long message that should be wrapped to fit within the terminal width.', print: print);
}
copied to clipboard

Contributing #

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contact #

Follow us, stay up to date or reach out on:


🚀 Founded by Ajay Kumar 🎉

1
likes
150
points
186
downloads

Publisher

verified publisherdart.nonstopio.com

Weekly Downloads

2024.09.14 - 2025.03.29

A shared utility package for CLI operations in Flutter Forge packages, providing utilities for CLI commands, Flutter project management, Melos workspace management, and file operations.

Homepage
Repository (GitHub)
View/report issues

Topics

#cli #utilities #melos #flutter

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

mason, mason_logger, meta, path, universal_io

More

Packages that depend on cli_core