code2text

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 9 Imported by: 0

README

code2text

Introduction

code2text is a CLI tool designed to walk through directories, collect code files based on specified filters, and consolidate their contents into a single text document. This tool is particularly useful for gathering code for analysis or archiving.

Installation

Prerequisites
  • Go (1.15 or later)
Install with Go
go install github.com/forrest321/code2text
Build from Source
  1. Clone the repository:
    git clone https://github.com/forrest321/code2text
    
  2. Navigate to the project directory:
    cd code2text
    
  3. Build the tool:
    go build -o code2text
    
  4. Move the created binary to a location within your PATH
    sudo mv code2text /usr/bin/
    

Usage

Run the tool using the following syntax:

If using code2text installed in path:

code2text [flags]

If using locally created code2text binary in the same folder:

./code2text [flags]

Defaults

IncludeExtensions: []string{".go", ".js", ".jsx", ".ts", ".tsx", ".py", ".rb", ".php", ".swift", ".c", ".cpp", ".h", ".hpp", ".java", ".rs", ".kt", ".scala", ".m"},
ExcludeExtensions: []string{".log", ".tmp", ".bak", ".o", ".obj", ".class", ".exe", ".dll", ".so", ".a", ".lib", ".pyc", ".jar"},
IgnoreDirs:        []string{".git", ".idea", ".vscode", "node_modules", "vendor", "build", "dist", "bin", "obj"},
OutputFile:        "output.txt"
Flags
  • -o, --output <file>: Specify the output file name (default is output.txt).
  • -i, --include <extensions>: Specify file extensions to include (default includes .go, .js).
  • -e, --exclude <extensions>: Specify file extensions to exclude.
  • -g, --ignore <directories>: Specify directories to ignore (default ignores .git, .idea).
Example

If using code2text installed in path:

code2text --output result.txt --include .go --include .js --exclude .test --ignore .git

If using locally created code2text binary in the same folder:

./code2text --output result.txt --include .go --include .js --exclude .test --ignore .git

Output Details

The output file begins with the directory structure, followed by the content of each file included in the scan. Each file's content is clearly separated and includes metadata about the file path and the number of lines.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL