slugcopy 1.0.0 → 2.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.
- package/README.md +57 -20
- package/cli.js +7 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,33 +1,70 @@
|
|
|
1
1
|
# slugcopy
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
> Slugify strings and copy them directly to your clipboard.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/slugcopy)
|
|
6
|
+
[](https://github.com/imranpollob/slugcopy/blob/master/license)
|
|
7
|
+
|
|
8
|
+
**slugcopy** is a lightweight command-line utility that converts any string into a URL-friendly slug and automatically copies the result to your system clipboard. It is built on top of the robust [`@sindresorhus/slugify`](https://github.com/sindresorhus/slugify) library.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🚀 **Instant Copy**: Automatically puts the result in your clipboard.
|
|
13
|
+
- 🛠 **Customizable**: Choose your separator, handle camelCase, and more.
|
|
14
|
+
- 📦 **Modern**: Built with modern Node.js standards.
|
|
15
|
+
- 🌐 **International**: Handles special characters (e.g., `Déjà Vu!` -> `deja-vu`).
|
|
3
16
|
|
|
4
17
|
## Install
|
|
5
18
|
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
Requires [Node.js](https://nodejs.org/) 18 or higher.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --global slugcopy
|
|
8
23
|
```
|
|
9
24
|
|
|
10
25
|
## Usage
|
|
11
26
|
|
|
27
|
+
```bash
|
|
28
|
+
$ slugcopy <string>
|
|
12
29
|
```
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
## Options
|
|
32
|
+
|
|
33
|
+
| Option | Description | Default |
|
|
34
|
+
| :------------------------------ | :--------------------------------- | :------------------- |
|
|
35
|
+
| `--separator=<string>` | Character to separate words | `-` |
|
|
36
|
+
| `--no-lowercase` | Preserve original casing | `true` (lowercases) |
|
|
37
|
+
| `--no-decamelize` | Preserve camelCase as single words | `true` (decamelizes) |
|
|
38
|
+
| `--preserve-leading-underscore` | Keep leading underscores | `false` |
|
|
39
|
+
| `--no-copy` | Do not copy result to clipboard | `false` (copies) |
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
**Basic Usage**
|
|
44
|
+
```bash
|
|
45
|
+
$ slugcopy "Déjà Vu!"
|
|
46
|
+
# Output: deja-vu
|
|
47
|
+
# Clipboard: deja-vu
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Custom Separator & Case Preservation**
|
|
51
|
+
```bash
|
|
52
|
+
$ slugcopy "Like a Boss" --no-lowercase --separator='_'
|
|
53
|
+
# Output: Like_a_Boss
|
|
54
|
+
# Clipboard: Like_a_Boss
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Skipping Clipboard Copy**
|
|
58
|
+
```bash
|
|
59
|
+
$ slugcopy "Just Print This" --no-copy
|
|
60
|
+
# Output: just-print-this
|
|
61
|
+
# Clipboard: (unchanged)
|
|
29
62
|
```
|
|
30
63
|
|
|
31
64
|
## Related
|
|
32
65
|
|
|
33
|
-
- [slugify-cli](https://github.com/sindresorhus/slugify-cli) -
|
|
66
|
+
- [slugify-cli](https://github.com/sindresorhus/slugify-cli) - The original inspiration for this project.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT © [Imran Pollob](https://github.com/imranpollob)
|
package/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import meow from "meow";
|
|
3
3
|
import slugify from "@sindresorhus/slugify";
|
|
4
|
-
import
|
|
4
|
+
import clipboardy from "clipboardy";
|
|
5
5
|
|
|
6
6
|
const cli = meow(
|
|
7
7
|
`
|
|
@@ -47,13 +47,16 @@ const cli = meow(
|
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
+
if (cli.input.length === 0) {
|
|
51
|
+
cli.showHelp();
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
const text = cli.input.join(" ");
|
|
51
55
|
const output = slugify(text, cli.flags);
|
|
52
56
|
|
|
53
57
|
console.log(output);
|
|
54
58
|
|
|
55
59
|
if (cli.flags.copy) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
60
|
+
clipboardy.writeSync(output);
|
|
61
|
+
console.log("Copied to clipboard");
|
|
59
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slugcopy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Slugify strings and copy to clipboard",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"bin": {
|
|
11
|
-
"slugcopy": "
|
|
11
|
+
"slugcopy": "cli.js"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
14
|
+
"node": ">=18"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/imranpollob/slugcopy#readme",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sindresorhus/slugify": "
|
|
43
|
-
"
|
|
44
|
-
"meow": "
|
|
42
|
+
"@sindresorhus/slugify": "3.0.0",
|
|
43
|
+
"clipboardy": "5.0.2",
|
|
44
|
+
"meow": "14.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"ava": "
|
|
48
|
-
"execa": "
|
|
47
|
+
"ava": "6.4.1",
|
|
48
|
+
"execa": "9.6.1"
|
|
49
49
|
}
|
|
50
50
|
}
|