Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CLI Tools with Node
Search
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
92
Como convencer seu time a mudar de tecnologia
hmschreiner
2
470
Javascript with Classes
hmschreiner
0
68
Other Decks in Programming
See All in Programming
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
ジョジョの世界をXRで再現する
mofurune
0
160
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
150
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
300
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
420
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
golang-bob.pdf
iwatsukayura
0
130
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
1k
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
880
Featured
See All Featured
Marketing to machines
jonoalderson
1
5.9k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Being A Developer After 40
akosma
92
590k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Leo the Paperboy
mayatellez
10
2.4k
Visualization
eitanlees
153
17k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Why Our Code Smells
bkeepers
PRO
340
58k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
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!