Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lightning Talks - 12 Factor CLI Apps

Lightning Talks - 12 Factor CLI Apps

oder: Eine Geschichte über User Experience, im geliebten und gleichzeitig gehassten Terminal.
Eine Sache haben doch fast alle Entwickler gemeinsam: Sie verabscheuen es mit aufgeblähter interner Software oder Webseiten mit hunderten Buttons und Dropdowns zu hantieren, nur weil man mal schnell etwas machen wollte.
Oft wenn im Büro ein Problem in AWS, Maven oder dem eigenen Computer gelöst werden muss, hört man als Tipp einen abstrusen Terminal Befehl vom anderen Ende des Büros.
Wir beschäftigen uns mit jedem noch so kleinen Detail der User Experience für unsere Kunden, müssen uns selbst jedoch jedes mal wenn wir mit dem Terminal ein .tar.gz Archiv entpacken wollen Googlen, denn das Kommando tar -xvzf arch.tar.gz ist alles andere als intuitiv.
Sind uns unsere (Mit-)Entwickler nicht genau so wichtig wie Endkunden? Wir gucken uns einige Ideen für intuitive und gut gelungene CLI Anwendungen an.

Jannis Schaefer

November 29, 2018
Tweet

More Decks by Jannis Schaefer

Other Decks in Technology

Transcript

  1. 12 Factor CLI Apps Eine Geschichte über User Experience, im

    geliebten und gleichzeitig gehassten Terminal. cosee GmbH, Jannis Schaefer, @jannisschaefer
  2. Do devs need good UX? I once extracted a .tar.gz

    … tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz tar -xJf archive.tar.xz #or newer tar --extract --xz --file archive.tar.xz What’s about .tar.xz?
  3. 1. How to get help? git --help git help git

    -h #also for subcommands git clone --help
  4. 2. Prefer flags to args usermod -aG docker jannis usermod

    -aG jannis docker Flags can be in random order Arguments not Usage: usermod [options] LOGIN Options: -c, --comment COMMENT new value of the GECOS field -d, --home HOME_DIR new home directory for the user account -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE -f, --inactive INACTIVE set password inactive after expiration to INACTIVE -g, --gid GROUP force use GROUP as new primary group -G, --groups GROUPS new list of supplementary GROUPS -a, --append append the user to the supplemental GROUPS mentioned by the -G option without removing him/her from other groups -h, --help display this help message and exit -l, --login NEW_LOGIN new value of the login name -L, --lock lock the user account -m, --move-home move contents of the home directory to the new location (use only with -d) -o, --non-unique allow using duplicate (non-unique) UID -p, --password PASSWORD use encrypted password for the new password -R, --root CHROOT_DIR directory to chroot into -s, --shell SHELL new login shell for the user account -u, --uid UID new UID for the user account -U, --unlock unlock the user account -v, --add-subuids FIRST-LAST add range of subordinate uids -V, --del-subuids FIRST-LAST remove range of subordinate uids -w, --add-subgids FIRST-LAST add range of subordinate gids -W, --del-subgids FIRST-LAST remove range of subordinate gids -Z, --selinux-user SEUSER new SELinux user mapping for the user account
  5. 3. What version am I on? Knowing the version helps

    finding bugs and documentation git version git --version ⇒ git version 2.19.2
  6. 4. Pipe it! $ curl ... > dl.txt stdout gets

    written to File stderr gets printed on TTY $ curl -v https://.../go1.11.2.osx.tar.gz > go1.11.2.tar.gz ===> Progress Bar (on StdErr)
  7. 5. Handle failures Step 1: Exit Code != 0 Step

    2: Error Title Users don’t need no traces $ git pul git: 'pul' ist kein Git-Befehl. Siehe 'git --help'. Die ähnlichsten Befehle sind pull push
  8. 5. Handle failures Step 1: Exit Code != 0 Step

    2: Error Title Users don’t need no traces $ git pull ssh: connect to host gitlab.com port 22: Network is down fatal: Konnte nicht vom Remote-Repository lesen. Bitte stellen Sie sicher, dass die korrekten Zugriffsberechtigungen bestehen und das Repository existiert.
  9. 6. Be fancy! Waiting is more fun with a progressbar!

    https://github.com/schollz/progressbar
  10. 6. Be fancy! – Color up your life We’re not

    in the 80s anymore! https://github.com/fatih/color
  11. 6. Be fancy! – But not when TERM=dumb If it’s

    not a TTY or when redirecting to File (github.com/mattn/go-isatty can help) Some terminals don’t support color codes Most CLI Apps behave different in that cases
  12. 7. Promt if you can Do more than just parse

    []args Prompting helps the user not needing README files before using your app.
  13. 8. Use tables $ kubectl --namespace stage get po |

    grep traefik traefik-stg-fdkjc 1/1 Running 0 7h traefik-stg-zxkjw 1/1 Running 0 7h
  14. 9. Respond fast People don’t want to use slow responding

    CLIs Hard for scripting language overhead
  15. 10. Make it easy to install Use tools for building

    brew or snap Packages Automate it! GoReleaser
  16. 11. Be clear about subcommands 2 common patterns: $ git

    submodule add [email protected]:... $ heroku domains:add www.cosee.biz
  17. 12. Follow XDG-spec Describes where to put application files Configs

    ~/.config/myapp Data files ~/.local/share/myapp Caching depends on system Librarys will guide you! XDG-spec