ccopy 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a932fe74c3a0c52f9d16b7979759c8d3acf7447599668ed5f227375f967d1f44
4
+ data.tar.gz: de17bae03d7e1443ee729a751c100623babb51c91534621cf1d6b80c5da52e35
5
+ SHA512:
6
+ metadata.gz: 5bc5115208fad720b9e7a5c6198ebccd0cac4e884ca765d86bc7e8e976ba1abdb03d5690c63e1220cb085c1eb6eab1a79fe610dd5aba61713bcea0df67d04e85
7
+ data.tar.gz: 3a2b98eb406a633ad1550f31801a38c994d83f2c7a2393bc4c874fe2ae430981ce4706143dde5913bdb8c3d0aa127eb972db85078520b4a25a64b383b4818413
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-08-01
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Jose Augusto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # ccopy
2
+
3
+ A simple, fast, and lightweight CLI tool to copy terminal output to clipboard.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Fast**
8
+ - 📦 **Lightweight**
9
+ - 🔄 **Cross-platform**: Works on Linux and macOS
10
+ - 📋 **Simple**: Just pipe any command output to `ccopy`
11
+ - 🎯 **Reliable**: Handles large outputs efficiently
12
+
13
+ ## Installation
14
+
15
+ ### Quick Install (Linux or Osx)
16
+ ```bash
17
+ gem install ccopy
18
+ ```
19
+
20
+ ### Build from Source
21
+
22
+ ```bash
23
+ git clone https://github.com/JAugusto42/ccopy.git
24
+ cd ccopy
25
+ make build
26
+ make install
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Simply pipe any command output to `ccopy`:
32
+
33
+ ```bash
34
+ # Copy file contents
35
+ cat file.txt | ccopy
36
+
37
+ # Copy directory listing
38
+ ls -la | ccopy
39
+
40
+ # Copy process list
41
+ ps aux | ccopy
42
+
43
+ # Copy API response
44
+ curl -s https://api.github.com/users/octocat | ccopy
45
+
46
+ # Copy command output
47
+ echo "Hello World" | ccopy
48
+
49
+ # Copy complex command chains
50
+ docker ps --format "table {{.Names}}\t{{.Status}}" | ccopy
51
+ ```
52
+
53
+ ## System Requirements
54
+
55
+ ### Linux
56
+ - **xclip** (recommended) or **xsel**
57
+ - Install with: `sudo apt install xclip` (Ubuntu/Debian) or `sudo dnf install xclip` (Fedora)
58
+
59
+ ### macOS
60
+ - **pbcopy** (built-in)
61
+
62
+ ## Examples
63
+
64
+ ### Development Workflow
65
+ ```bash
66
+ # Copy git log
67
+ git log --oneline -10 | ccopy
68
+
69
+ # Copy current directory structure
70
+ tree | ccopy
71
+ ```
72
+
73
+ ### System Administration
74
+ ```bash
75
+ # Copy system information
76
+ uname -a | ccopy
77
+
78
+ # Copy disk usage
79
+ df -h | ccopy
80
+
81
+ # Copy network configuration
82
+ ip addr show | ccopy
83
+ ```
84
+
85
+ ### File Processing
86
+ ```bash
87
+ # Copy filtered logs
88
+ tail -f /var/log/nginx/access.log | grep ERROR | ccopy
89
+
90
+ # Copy search results
91
+ grep -r "TODO" src/ | ccopy
92
+ ```
93
+
94
+ ## Build Options
95
+
96
+ ```bash
97
+ # Build for current platform
98
+ make build
99
+
100
+ # Build for all platforms
101
+ make build-all
102
+
103
+ # Install system-wide
104
+ make install
105
+
106
+ # Install for current user
107
+ make install-user
108
+
109
+ # Create release packages
110
+ make release
111
+
112
+ # Clean build artifacts
113
+ make clean
114
+ ```
115
+
116
+ ## Platform Support
117
+
118
+ | Platform | Architecture | Status |
119
+ |----------|--------------|--------|
120
+ | Linux | amd64 | ✅ |
121
+ | Linux | arm64 | ✅ |
122
+ | macOS | amd64 | ✅ |
123
+ | macOS | arm64 | ✅ |
124
+
125
+ ## Contributing
126
+
127
+ 1. Fork the repository
128
+ 2. Create a feature branch: `git checkout -b feature-name`
129
+ 3. Make your changes
130
+ 4. Run tests: `make test`
131
+ 5. Submit a pull request
132
+
133
+ ## License
134
+
135
+ MIT License - see [LICENSE](LICENSE) file for details.
136
+
137
+ ## Troubleshooting
138
+
139
+ ### "xclip or xsel not found" Error
140
+
141
+ **Solution**: Install clipboard utilities:
142
+ ```bash
143
+ # Ubuntu/Debian
144
+ sudo apt install xclip
145
+
146
+ # Fedora/CentOS
147
+ sudo dnf install xclip
148
+
149
+ # Arch Linux
150
+ sudo pacman -S xclip
151
+ ```
152
+
153
+ ### Command Not Found
154
+
155
+ **Solution**: Ensure the binary is in your PATH:
156
+ ```bash
157
+ # Check if ccopy is in PATH
158
+ which ccopy
159
+
160
+ # If not, add to PATH (add to ~/.bashrc for persistence)
161
+ export PATH="$HOME/.local/bin:$PATH"
162
+ ```
163
+
164
+ ### Large Output Issues
165
+
166
+ **Solution**: ccopy handles large outputs efficiently, but for extremely large data:
167
+ ```bash
168
+ # Use with head/tail for large files
169
+ head -1000 large_file.txt | ccopy
170
+ tail -100 /var/log/system.log | ccopy
171
+ ```
172
+
173
+ ## FAQ
174
+
175
+ **Q: Does ccopy work with all shells?**
176
+ A: Yes, ccopy works with bash, zsh, fish, and any POSIX-compliant shell.
177
+
178
+ **Q: Can I copy binary data?**
179
+ A: ccopy is designed for text data. Binary data may not clipboard properly.
180
+
181
+ **Q: How much data can ccopy handle?**
182
+ A: ccopy can handle several MB of text data efficiently.
183
+
184
+ **Q: Does ccopy work over SSH?**
185
+ A: Yes, but clipboard integration depends on your terminal and SSH client configuration.
186
+
187
+ ## Alternatives
188
+
189
+ - `xclip` - X11 clipboard utility
190
+ - `xsel` - X selection utility
191
+ - `pbcopy` - macOS clipboard utility
192
+ - `wl-clipboard` - Wayland clipboard utility
193
+
194
+ ## Changelog
195
+
196
+ ### v1.0.0
197
+ - Initial release
198
+ - Cross-platform support
199
+ - Automatic clipboard utility detection
200
+ - Error handling and help system
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/ccopy ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'ccopy'
5
+
6
+ # Call the main service
7
+ Ccopy::Main.call(*ARGV)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ccopy
4
+ VERSION = "1.0.0"
5
+ end
data/lib/ccopy.rb ADDED
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ccopy/version"
4
+ require 'rbconfig'
5
+
6
+ module Ccopy
7
+ class Error < StandardError; end
8
+
9
+ class Main
10
+ def self.call(*args)
11
+ @debug = args.include?("--debug")
12
+
13
+ if args.include?("-h") || args.include?("--help") || $stdin.tty?
14
+ show_help
15
+ return
16
+ end
17
+
18
+ input = $stdin.read
19
+ copy_to_clipboard(input)
20
+ puts "Copied to clipboard!"
21
+ end
22
+
23
+ def self.copy_to_clipboard(text)
24
+ debug_puts "Text to be copied: #{text.inspect}"
25
+ debug_puts "Host OS: #{RbConfig::CONFIG['host_os']}"
26
+
27
+ case RbConfig::CONFIG["host_os"]
28
+ when /darwin/
29
+ debug_puts "Using pbcopy for macOS"
30
+ IO.popen("pbcopy", "w") do |io|
31
+ io.write(text)
32
+ debug_puts "written in pipe"
33
+ end
34
+ debug_puts "pbcopy executed successfully"
35
+ when /linux/
36
+ debug_puts "Using xclip for Linux"
37
+ IO.popen("xclip -selection clipboard", "w") { |io| io.write(text) }
38
+ debug_puts "xclip executed successfully"
39
+ end
40
+ rescue StandardError => e
41
+ puts "Error copying to clipboard: #{e}"
42
+ if @debug
43
+ puts "Error class: #{e.class}"
44
+ puts "Error backtrace: #{e.backtrace.join("\n")}"
45
+ end
46
+ end
47
+
48
+ def self.show_help
49
+ puts "ccopy - Copy stdin to clipboard"
50
+ puts ""
51
+ puts "Usage:"
52
+ puts " <command> | ccopy [options]"
53
+ puts ""
54
+ puts "Examples:"
55
+ puts " cat file.txt | ccopy"
56
+ puts " ls -la | ccopy"
57
+ puts " echo 'hello world' | ccopy --debug"
58
+ puts " curl -s api.example.com/data | ccopy"
59
+ puts ""
60
+ puts "Options:"
61
+ puts " -h, --help Show this help message"
62
+ puts " --debug Show debug information"
63
+ puts ""
64
+ puts "Description:"
65
+ puts " ccopy reads from stdin and copies the content to the system clipboard."
66
+ puts " Works on macOS (pbcopy) and Linux (xclip)."
67
+ end
68
+
69
+ def self.debug_puts(message)
70
+ puts "Debug: #{message}" if @debug
71
+ end
72
+ end
73
+ end
data/sig/ccopy.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Ccopy
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ccopy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jose Augusto
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: A simple command-line tool that copies stdin output to the system clipboard. Perfect
13
+ for piping command outputs directly to clipboard.
14
+ email:
15
+ - joseaugusto.881@outlook.com
16
+ executables:
17
+ - ccopy
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - exe/ccopy
27
+ - lib/ccopy.rb
28
+ - lib/ccopy/version.rb
29
+ - sig/ccopy.rbs
30
+ homepage: https://github.com/JAugusto42/ccopy
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ allowed_push_host: https://rubygems.org
35
+ homepage_uri: https://github.com/JAugusto42/ccopy
36
+ source_code_uri: https://github.com/JAugusto42/ccopy
37
+ changelog_uri: https://github.com/JAugusto42/ccopy/blob/main/CHANGELOG.md
38
+ rubygems_mfa_required: 'true'
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.2.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.7.1
54
+ specification_version: 4
55
+ summary: CLI tool to copy stdin to clipboard
56
+ test_files: []