Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CLI Tools with Node
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Henrique Schreiner
November 02, 2016
Programming
69
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CLI Tools with Node
Learn how you can easily create your own CLI (Command Line Interface) tool with Node.js.
Henrique Schreiner
November 02, 2016
More Decks by Henrique Schreiner
See All by Henrique Schreiner
Testando Componentes React com Jest e Enzyme
hmschreiner
0
91
Como convencer seu time a mudar de tecnologia
hmschreiner
2
470
Javascript with Classes
hmschreiner
0
66
Other Decks in Programming
See All in Programming
Building a Meta Ray-Ban display app
akkeylab
0
170
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
280
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
3
1.3k
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
560
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
450
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
140
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.6k
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
330
Hono + Inertia + React で LP を構築した話
oukayuka
2
130
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
240
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
240
MySQLとPostgreSQLって何が違うの?
akagami
0
120
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
108
250k
From π to Pie charts
rasagy
0
310
Are puppies a ranking factor?
jonoalderson
2
3.8k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The SEO identity crisis: Don't let AI make you average
varn
0
530
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
280
Navigating Team Friction
lara
192
16k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
BBQ
matthewcrist
89
10k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
810
Transcript
CLI Tools with Node @hmschreiner
root@hmschreiner : $ whoami # Henrique Schreiner Software Developer at
e-Core @hmschreiner linkedin.com/in/HenriqueSchreiner e-core.com/pt/carreiras
# Creating the Project
root@hmschreiner : ~/my-tool-folder $ npm init name: file-search version: 1.0.0
description: My CLI tool to search files entry point: index.js test command: git repository: keywords: author: Henrique Schreiner license: (ISC)
{ "name": "file-search", "version": "1.0.0", "description": "My CLI tool to
search files", "main": "index.js", "author": "Henrique Schreiner", "license": "ISC" } Is this ok? (yes) root@hmschreiner : ~/my-tool-folder $ npm init
# Editing package.json
{ "name": "file-search", "version": "1.0.0", "description": "My CLI tool to
search files", "main": "index.js", "author": "Henrique Schreiner", "license": "ISC", }
{ "name": "file-search", "version": "1.0.0", "description": "My CLI tool to
search files", "author": "Henrique Schreiner", "license": "ISC", "preferGlobal": true, "bin": { "file-search": "index.js" } }
# Creating the Script
root@hmschreiner : ~/my-tool-folder $ vim index.js #!/usr/bin/env node --harmony 'use
strict'; console.log('This is the file-search script.');
# Installing the Script
root@hmschreiner : ~/my-tool-folder $ npm link - Install the script
on your system - Creates a symlink to your project so that you can run the project whilst working on it - No need to keep reinstalling it over and over again
root@hmschreiner : ~ $ file-search This is the file-search script.
# Processing Arguments
root@hmschreiner : ~/my-tool-folder $ vim index.js #!/usr/bin/env node --harmony 'use
strict'; console.log(process.argv);
root@hmschreiner : ~ $ file-search hello [ 'node', '/Users/hmschreiner/bin/file-search', 'hello'
]
root@hmschreiner : ~/my-tool-folder $ vim index.js #!/usr/bin/env node --harmony 'use
strict'; let inputArgs = process.argv.slice(2); let searchPattern = inputArgs[0];
# Searching for Files
root@hmschreiner : ~/my-tool-folder $ vim index.js #!/usr/bin/env node --harmony 'use
strict'; const exec = require('child_process').exec; let inputArgs = process.argv.slice(2); let searchPattern = inputArgs[0]; exec(`ls -a | grep ${searchPattern}`, (err, stdout, stderr) => { console.log(stdout); });
root@hmschreiner : ~/my-tool-folder $ file-search package package.json
# Next Steps
root@hmschreiner : ~/my-tool-folder $ npm publish - Ensure a good,
well written README file - Decide on an initial version number (e.g. 1.0.0) - If you’ve not registered on npm...
root@hmschreiner : ~/my-tool-folder $ npm adduser - Follow the prompts
to set up and authenticate yourself - Once published, users can then install your module
root@hmschreiner : ~ $ npm install --g file-search /usr/local/lib └─┬
[email protected]
...
# Thank You!