npm package: @manalejandro/textbin2bintext
Description: A CLI utility to convert text to binary and binary to text
Author: ale
Latest version: 1.0.0

# @manalejandro/textbin2bintext

A versatile CLI utility and Node.js module for converting text to binary and binary to text. This package provides both programmatic and command-line interfaces for seamless text-binary conversions.

## 🚀 Features

- Convert text to binary representation
- Convert binary back to readable text
- Command-line interface with intuitive commands
- File input/output support
- Short command aliases for quick usage
- Comprehensive error handling
- ESM (ES Modules) support

## 📦 Installation

### Global Installation (CLI usage)
```bash
npm install -g @manalejandro/textbin2bintext
```

### Local Installation (Programmatic usage)
```bash
npm install @manalejandro/textbin2bintext
```

## 🔧 CLI Usage

After global installation, you can use the `textbin2bintext` command:

### Basic Commands

```bash
# Convert text to binary
textbin2bintext text2bin "Hello World"
textbin2bintext t2b "Hello World"

# Convert binary to text
textbin2bintext bin2text "0100100001100101011011000110110001101111"
textbin2bintext b2t "0100100001100101011011000110110001101111"
```

### File Operations

```bash
# Read input from file
textbin2bintext text2bin -f input.txt

# Write output to file
textbin2bintext bin2text -f binary.txt -o output.txt

# Chain operations: read from file and write to another
textbin2bintext text2bin -f message.txt -o binary_output.txt
```

### Help and Version

```bash
# Show help
textbin2bintext --help
textbin2bintext help

# Show version
textbin2bintext --version
textbin2bintext version
```

## 📚 Programmatic Usage

### ES Modules (ESM)

```javascript
import { textToBin, binToText } from '@manalejandro/textbin2bintext';

// Convert text to binary
const binaryResult = textToBin("Hello World");
console.log(binaryResult);
// Output: 0100100001100101011011000110110001101111...

// Convert binary to text
const textResult = binToText("0100100001100101011011000110110001101111");
console.log(textResult);
// Output: Hello
```

### Default Export

```javascript
import textbin2bintext from '@manalejandro/textbin2bintext';

const binary = textbin2bintext.textToBin("Hello");
const text = textbin2bintext.binToText("0100100001100101011011000110110001101111");
```

## 🎯 Command Reference

### Commands

| Command | Alias | Description |
|---------|-------|-------------|
| `text2bin` | `t2b` | Convert text to binary |
| `bin2text` | `b2t` | Convert binary to text |
| `help` | `-h`, `--help` | Show help message |
| `version` | `-v`, `--version` | Show version |

### Options

| Option | Alias | Description |
|--------|-------|-------------|
| `--file` | `-f` | Read input from file |
| `--output` | `-o` | Write output to file |

## 📖 Examples

### CLI Examples

```bash
# Simple conversions
textbin2bintext t2b "Node.js"
textbin2bintext b2t "0100111001101111011001000110010100101110011010100111001100"

# Working with files
echo "Hello, World!" > message.txt
textbin2bintext text2bin -f message.txt -o message.bin
textbin2bintext bin2text -f message.bin
```

### Programmatic Examples

```javascript
import { textToBin, binToText } from '@manalejandro/textbin2bintext';

// Convert a message
const message = "JavaScript is awesome!";
const binary = textToBin(message);
console.log(`Binary: ${binary}`);

// Convert back
const originalMessage = binToText(binary);
console.log(`Original: ${originalMessage}`);

// Error handling
try {
    const result = binToText("invalid_binary");
} catch (error) {
    console.error("Conversion failed:", error.message);
}
```

## 🔍 API Reference

### `textToBin(text: string): string`

Converts text to binary representation.

**Parameters:**
- `text` (string): The text to convert to binary

**Returns:**
- `string`: Binary representation of the input text

### `binToText(binary: string): string`

Converts binary representation back to text.

**Parameters:**
- `binary` (string): The binary string to convert to text

**Returns:**
- `string`: Text representation of the input binary

## 🛠️ Development

### Local Development

```bash
# Clone the repository
git clone <repository-url>
cd textbin2bintext

# Install dependencies
npm install

# Test the CLI locally
node cli.js text2bin "Test message"
```

### Testing

```bash
# Test text to binary conversion
node cli.js t2b "Hello World"

# Test binary to text conversion
node cli.js b2t "0100100001100101011011000110110001101111"

# Test file operations
echo "Test content" > test.txt
node cli.js text2bin -f test.txt -o output.bin
node cli.js bin2text -f output.bin
```

## 📄 Dependencies

- [@manalejandro/text2bin](https://www.npmjs.com/package/@manalejandro/text2bin) - Core text to binary conversion
- [@manalejandro/bin2text](https://www.npmjs.com/package/@manalejandro/bin2text) - Core binary to text conversion

## 📝 License

MIT License - see the [LICENSE](LICENSE) file for details.

## 👤 Author

**ale**

## 🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

## 📊 Keywords

text, binary, conversion, cli, command-line, utility, text2bin, bin2text, node.js, javascript

---

Made with ❤️ by ale