An open API service indexing awesome lists of open source software.

https://github.com/moinsen-dev/moinsen_cli

Say Moinsen to your Flutter projects - A helpful Command Line Interface for Flutter projects.
https://github.com/moinsen-dev/moinsen_cli

ai cli dart flutter kickstart

Last synced: about 1 year ago
JSON representation

Say Moinsen to your Flutter projects - A helpful Command Line Interface for Flutter projects.

Awesome Lists containing this project

README

          

## moinsen_cli

![coverage][coverage_badge]
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[![License: MIT][license_badge]][license_link]

Generated by the [Very Good CLI][very_good_cli_link] ๐Ÿค–

A powerful CLI tool to help you with your Flutter projects. Provides a gRPC server for executing commands with real-time feedback and interactive support.

---

## Getting Started ๐Ÿš€

If the CLI application is available on [pub](https://pub.dev), activate globally via:

```sh
dart pub global activate moinsen_cli
```

Or locally via:

```sh
dart pub global activate --source=path
```

## Usage

```sh
# Start the gRPC server (default port: 50051)
$ moinsen serve

# Start the gRPC server on a specific port
$ moinsen serve --port 50052

# Start the server with auto-generated secure access key
$ moinsen serve --secret

# Start the server with a specific secret key
$ moinsen serve --secret-key your_secret_key

# Start the server with command logging enabled
$ moinsen serve --log

# Update the CLI to the latest version
$ moinsen update

# Show CLI version
$ moinsen --version

# Show usage help
$ moinsen --help
```

## Features

- gRPC command service with bidirectional streaming
- Interactive command support with prompt detection
- Secure server access with auto-generated or custom secret keys
- Command logging with timestamps and execution details
- Automatic CLI updates via pub.dev
- Graceful server shutdown handling
- Real-time command execution with detailed responses
- Cross-platform support

## Command Service Protocol

The CLI provides a gRPC service for executing commands with the following features:

- Bidirectional streaming for real-time command execution
- Interactive command support (e.g., handling y/n prompts)
- Response includes:
- Command output
- Current working directory
- Timestamp
- Interactive prompt detection
- Error handling with stderr output

### Protocol Messages

```protobuf
message CommandRequest {
string session_id = 1;
string input_data = 2;
bool is_interactive_answer = 3;
}

message CommandResponse {
string session_id = 1;
string output_data = 2;
bool is_prompt = 3;
int64 timestamp = 4; // Unix timestamp in milliseconds
string current_folder = 5; // Current working directory
}
```

## Available Commands

### serve
Starts the gRPC server for command execution.

Options:
- `--port, -p`: Port to listen on (default: 50051)
- `--secret`: Enable secure server access with an auto-generated secret key
- `--secret-key`: Provide a specific secret key for server access
- `--log`: Enable command logging to `.moinsen-command-log.json`

### update
Updates the CLI to the latest version from pub.dev.

## Development

### Running Tests with Coverage ๐Ÿงช

To run all unit tests use the following command:

```sh
$ dart pub global activate coverage 1.2.0
$ dart test --coverage=coverage
$ dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
```

To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov):

```sh
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
$ open coverage/index.html
```

### Generating Protocol Buffers

To regenerate the gRPC code from protocol buffer definitions:

```sh
$ protoc --dart_out=grpc:lib/src/generated -Iprotos protos/command.proto
```

---

[coverage_badge]: coverage_badge.svg
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
[very_good_cli_link]: https://github.com/VeryGoodOpenSource/very_good_cli