heyduck 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. package/README.md +161 -0
  2. package/package.json +21 -5
  3. package/script.js +19 -2
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # heyduck
2
+
3
+ A fast and minimal CLI tool to search DuckDuckGo directly from your terminal and get clean, actionable results with links.
4
+
5
+ ---
6
+
7
+ ## 🚀 Features
8
+
9
+ * Instant DuckDuckGo search from terminal
10
+ * Clean formatted output using ANSI + chalk styling
11
+ * Quick link-first results for fast navigation
12
+ * JSON output mode for scripting
13
+ * Raw text mode for minimal output
14
+ * Control number of results
15
+
16
+ ---
17
+
18
+ ## 📦 Installation
19
+
20
+ ```bash
21
+ npm install -g heyduck
22
+ ```
23
+
24
+ ---
25
+
26
+ ## ⚡ Usage
27
+
28
+ ```bash
29
+ heyduck <keywords>
30
+ ```
31
+
32
+ Example:
33
+
34
+ ```bash
35
+ heyduck nodejs event loop
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 🎛️ Options
41
+
42
+ ### Limit results
43
+
44
+ ```bash
45
+ heyduck <keywords> -r <number>
46
+ ```
47
+
48
+ Example:
49
+
50
+ ```bash
51
+ heyduck javascript promises -r 5
52
+ ```
53
+
54
+ ---
55
+
56
+ ### JSON output
57
+
58
+ ```bash
59
+ heyduck <keywords> -j
60
+ ```
61
+
62
+ Example:
63
+
64
+ ```bash
65
+ heyduck react hooks -j
66
+ ```
67
+
68
+ ---
69
+
70
+ ### Raw text output
71
+
72
+ ```bash
73
+ heyduck <keywords> -t
74
+ ```
75
+
76
+ Example:
77
+
78
+ ```bash
79
+ heyduck docker basics -t
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 🧠 How it works
85
+
86
+ heyduck sends a request to DuckDuckGo, parses the results, and extracts titles, links, and snippets. It then formats them for terminal display or returns structured data depending on flags.
87
+
88
+ ---
89
+
90
+ ## 🧩 Flags
91
+
92
+ | Flag | Description |
93
+ | ---- | ------------------------------- |
94
+ | `-r` | Number of results to display |
95
+ | `-j` | Output results as JSON |
96
+ | `-t` | Output raw text without styling |
97
+
98
+ ---
99
+
100
+ ## 💡 Examples
101
+
102
+ ### Basic search
103
+
104
+ ```bash
105
+ heyduck linux file permissions
106
+ ```
107
+
108
+ ### Limited results
109
+
110
+ ```bash
111
+ heyduck npm publish package -r 3
112
+ ```
113
+
114
+ ### JSON output
115
+
116
+ ```bash
117
+ heyduck async await -j
118
+ ```
119
+
120
+ ### Raw output
121
+
122
+ ```bash
123
+ heyduck git rebase -t
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 🛠️ Tech Stack
129
+
130
+ * Node.js
131
+ * Axios (HTTP requests)
132
+ * Cheerio (HTML parsing)
133
+ * Chalk (terminal styling)
134
+ * ANSI formatting
135
+
136
+ ---
137
+
138
+ ## 📌 Use Cases
139
+
140
+ * Quick developer searches without opening browser
141
+ * Copying links directly from terminal
142
+ * Scripting search workflows
143
+ * Lightweight research tool
144
+
145
+ ---
146
+
147
+ ## 📄 License
148
+
149
+ MIT
150
+
151
+ ---
152
+
153
+ ## 🤝 Contributing
154
+
155
+ Pull requests and suggestions are welcome.
156
+
157
+ ---
158
+
159
+ ## 🔥 Author
160
+
161
+ Built for fast terminal-based searching with focus on speed, simplicity, and usability.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "heyduck",
3
- "version": "1.0.0",
4
- "description": "",
3
+ "version": "1.0.1",
4
+ "description": "A fast CLI tool to search DuckDuckGo and instantly get keyword-based results with links, formatted output, JSON support, and customizable result limits.",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -10,8 +10,24 @@
10
10
  "bin": {
11
11
  "heyduck": "./script.js"
12
12
  },
13
- "keywords": [],
14
- "author": "",
13
+ "keywords": [
14
+ "cli",
15
+ "search",
16
+ "duckduckgo",
17
+ "terminal",
18
+ "command-line",
19
+ "scraper",
20
+ "search-engine",
21
+ "productivity",
22
+ "developer-tools",
23
+ "nodejs",
24
+ "automation",
25
+ "cli-tool",
26
+ "json-output",
27
+ "web-search",
28
+ "fast-search"
29
+ ],
30
+ "author": "aliashraf34",
15
31
  "license": "ISC",
16
32
  "packageManager": "pnpm@10.30.3",
17
33
  "dependencies": {
@@ -20,4 +36,4 @@
20
36
  "cheerio": "^1.2.0",
21
37
  "wrap-ansi": "^10.0.0"
22
38
  }
23
- }
39
+ }
package/script.js CHANGED
@@ -10,6 +10,11 @@ const AXIOS_CFG = { headers: { "User-Agent": "Mozilla/5.0" }, timeout: 8000 };
10
10
  async function searchMetaTUI(keyword, max = 10, mode = "chalk") {
11
11
  const { data } = await axios.get(`https://duckduckgo.com/html/?q=${encodeURIComponent(keyword)}`, AXIOS_CFG);
12
12
 
13
+ if (!data) {
14
+ console.log("Error: Could not get results from duck duck go.");
15
+ process.exit(1);
16
+ }
17
+
13
18
  const $ = cheerio.load(data);
14
19
  const results = [];
15
20
 
@@ -65,7 +70,19 @@ async function searchMetaTUI(keyword, max = 10, mode = "chalk") {
65
70
  const args = process.argv.slice(2);
66
71
 
67
72
  // Determine mode
68
- const mode = args.includes("-j") ? "json" : args.includes("-t") ? "text" : "chalk";
73
+ const mode = args.includes("-j") && args.includes("-t") ? null : args.includes("-j") ? "json" : args.includes("-t") ? "text" : "chalk";
74
+
75
+ if (mode === null) {
76
+ console.log("Error: -j and -t cannot be used together.");
77
+ process.exit(1);
78
+ }
79
+
80
+ if (rIndex !== -1 && (maxResults < 1 || maxResults > 10)) {
81
+ console.log("Error: -r must be between 1 and 10.");
82
+ process.exit(1);
83
+ }
84
+
85
+
69
86
 
70
87
  // Determine number of results with -r flag
71
88
  let maxResults = 10;
@@ -75,7 +92,7 @@ if (rIndex !== -1 && args[rIndex + 1] && !isNaN(args[rIndex + 1])) {
75
92
  }
76
93
 
77
94
  // Combine all other args as keyword
78
- const keyword = args.filter(arg => !arg.startsWith("-") && arg !== args[rIndex + 1]).join(" ");
95
+ const keyword = args.filter((arg, i) => !arg.startsWith("-") && (rIndex === -1 || i !== rIndex + 1)).join(" ");
79
96
 
80
97
  if (!keyword) {
81
98
  console.log("Usage: node script.js <search keyword> [-j|-t] [-r number]");