node command line interfaces
Всем привет ( ゚▽゚ )/

@_lrlna

@lrlna
node command line interfaces
node command line interfaces,
the hot take
o(*^▽^*)o
I <3 linux
4GB of RAM 💻
I <3 CLIs
            yourCoolCli -rgb global-status --latest -m
          
            yourCoolCli -rgb global-status --latest -m
          
monday
          yourCoolCli -rgb global-status --latest -m
          
tuesday
          yourCoolCli -rgb global-status --latest -m
          
wednesday
          yourCoolCli -rgb global-status --latest -m
          
thursday
          yourCoolCli -rgb global-status --latest -m
          
friday
(つ◕౪◕)つ━☆゚.*・。゚
          yourCoolCli -rgb global-status --latest -m
          
            yourCoolCli -rgb global-status --latest -m
          
ok, cool, so what's a command line module anyway?
git rebase -i sha
npm i pckg@latest --save
ls -a1
cowsay yo hollyjs
ok, cool, so what's a command line module anyway?
Command Line Interface is a means of interacting with a computer program where the user issues commands to the program in the form of successive lines of text.
issues commands to the program
issues commands interacts the program
ok, cool, so what's a command line module anyway?
unix
unix interface design patterns
filter
use in other programs
sink
source
ed pattern
roguelike
spooler/deamon

github.com/lrlna/sketchin
Irina's guide to interactivity™
            yourCoolCli -rgb global-status --latest -m
          
how easy is it for your teammate to start your workflow?
so you want to write a command line module ٩( ´・ш・ )و

🤖 --> bash?

🤖 --> ruby?

🤖 --> perl?

🤖 --> node.
(ノ´ロ`)ノ
argument parsing
process.argv.slice(2)

🤖 --> node.
Irina's guide to interactivity™
Level 1
Argument parsing



github.com/yargs
--options, -o
git reabse -i fb5f13 
level 2
give your options aliases
          var argv = require('yargs')
            .usage('Usage: $0 -n [string] -f [string]')
            .option('n', {
              alias: 'name',
              describe: 'Twitter name of your choosing',
              type: 'string',
              demand: true
            })
          
          twitter-node-name --name ira<2728>
          
          twitter-node-name -n ira<2728>
          
level 3
set up default values
          .option("yellow", {
            alias: "y",
            describe: "yellow wombat",
            type: "boolean",
            default: true
          })
          
level 4
provide a help menu
protip: use standardized CLI usage patterns
          var argv = require('yargs')
             // all your options and commands, yo
            .help()
            .argv
          
level 5
get input from users
or working with roguelikepatterns
github.com/flatiron/prompt
          prompt.start()
          prompt.get(getPromptSchema(), function(err, result) {
            // do thang with result o(*^▽^*)o
          })
          
create schema to return back
          return schema = {
            properties: {
              initial: {
                description: 'intial number of cats',
              },
              current: {
                description: 'current number of cats'
              },
              age: {
                description: 'your age'
              }
            }
          }
          
github.com/SBoudrias/Inquirer.js
          inquirer.prompt(getQuestions()).then(function(answers) {
            // do the thang with answers o(*^▽^*)o
          })
          
            {
              type: 'list',
              name: 'server',
              message: 'which server is this deploy going to?',
              choices: ['staging', 'production'],
              default: 'staging'
            }
            
level 6
how easy is it for your teammate to start your workflow?
filter
interactivity == simplicity
level 6
commands?
sources
User Interfaces, BBC
User Interface Design Patterns
CLI Usage Patterns from docopt Rogue
lrlna.github.io/holyjs-2016
Спасибо, Москва!!
(۶•̀ᴗ•́)۶