Project

concat.rb

0.0
The project is in a healthy, maintained state
A simple CLI tool that recursively reads files from directories and outputs their contents with file path comments. Supports filtering by file extensions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 5.0
~> 13.0
~> 1.21
~> 0.9
 Project Readme

concat.rb

Concatenate files from directories into a single output, with the ability to reverse the process.

Install

gem install concat.rb

Usage

concat

Recursively read files from directories and output their contents with file path comments.

# Concatenate all files in a directory
concat src/

# Filter by file extensions
concat lib/ --extensions=rb,py

# Multiple directories
concat src/ lib/ --extensions=js,ts

# Save to a file
concat app/ --extensions=rb > backup.txt

Example output:

# File path: ./lib/concat.rb
# frozen_string_literal: true

require_relative "concat/version"

module Concat
end

# File path: ./lib/concat/version.rb
# frozen_string_literal: true

module Concat
  VERSION = "1.0.0"
end

deconcat

Restore files from concatenated output. Reads from stdin and writes files to their original paths.

# Restore from a file
cat backup.txt | deconcat

# Pipe directly
concat lib/ --extensions=rb | deconcat

Clipboard integration

Use clip.rb to copy concatenated output to your clipboard:

# Copy to clipboard
concat lib/ --extensions=rb | clip

# Append to clipboard
concat src/ | clip --append

# Restore from clipboard
clip | deconcat

Contributing

Bug reports and pull requests are welcome on GitHub.

Development

After checking out the repo:

bin/setup
bundle exec rake test

Generate documentation:

bundle exec yard doc
bundle exec yard server  # Browse at http://localhost:8808

License

The gem is available as open source under the terms of the MIT License.