Categorygithub.com/will-wright-eng/parse
modulepackage
0.0.0-20250113013423-db8d82a40784
Repository: https://github.com/will-wright-eng/parse.git
Documentation: pkg.go.dev

# README

Markdown File Generator CLI

A command-line tool that generates files and directory structures from markdown files. This tool allows you to define your project structure and file contents in a markdown file and automatically generates the corresponding files and directories.

Features

  • šŸ”„ Generate files and directories from markdown specifications
  • šŸ“ Support for multiple markdown header formats

Installation

From Source

# Clone the repository
git clone https://github.com/will-wright-eng/parse
cd parse

# Initialize the project
make init

# Build the project
make build

# Optionally, install to your ~/.go/bin
make install

Prerequisites

  • Go 1.21 or higher
  • Make (for using the Makefile commands)

Usage

Basic Command

parse generate -i input.md -o output_dir

Available Flags

  • -i, --input: Input markdown file (required)
  • -o, --output: Output directory (default: "./tmp")
  • -f, --force: Force overwrite existing files
  • --strip-comments: Strip comments from code blocks
  • --skip: Patterns of files to skip (e.g., ".tmp,.bak")

Markdown File Format

The tool supports multiple formats for specifying files in your markdown:

## path/to/file1.txt
```python
def hello():
    print("Hello")
```

file: path/to/file2.js
```javascript
console.log('Hello');
```

path/to/file3.go
```go
package main

func main() {
    println("Hello")
}
```

Project Structure

.
ā”œā”€ā”€ Makefile              # Build and development commands
ā”œā”€ā”€ README.md            # Project documentation
ā”œā”€ā”€ cmd/                 # Command-line interface
│   ā”œā”€ā”€ generate.go      # Generate command implementation
│   ā”œā”€ā”€ root.go         # Root command configuration
│   └── version.go      # Version command
ā”œā”€ā”€ internal/           # Internal packages
│   ā”œā”€ā”€ config/        # Configuration handling
│   ā”œā”€ā”€ generator/     # File generation logic
│   ā”œā”€ā”€ logger/        # Logging utilities
│   ā”œā”€ā”€ parser/        # Markdown parsing
│   └── version/       # Version information
└── main.go            # Application entry point

Development

Available Make Commands

Usage: make [command]

Commands:
  help             Display this help screen
  init             Project initialization
  add-pkgs         Add packages to go.mod
  run              Run the application
  run-generate     Run the generate command
  watch            Run the application with live reload
  build            Build the application
  build-linux      Build for Linux
  build-darwin     Build for macOS
  build-windows    Build for Windows
  test             Run tests
  test-coverage    Generate test coverage report
  benchmark        Run benchmarks
  lint             Run linters
  fmt              Format code
  vet              Run go vet
  deps             Install dependencies
  deps-update      Update dependencies
  clean            Clean build artifacts
  install          Install the application
  uninstall        Uninstall the application
  envs             Print environment variables

Example file format

config/settings.json

```json
{
"environment": "development",
"port": 3000,
"database": {
    "host": "localhost",
    "port": 5432
}
}
```

src/main.js

```javascript
console.log('Application starting...');
```

Running:

parse generate -i template.md -o myproject

Will create:

myproject/
ā”œā”€ā”€ config/
│   └── settings.json
└── src/
    └── main.js

Built with ā¤ļø using Go

# Packages

cmd/generate.go.