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

Go - CLI Tools Design

Go - CLI Tools Design

Shintaro Kaneko

November 03, 2018
Tweet

More Decks by Shintaro Kaneko

Other Decks in Programming

Transcript

  1. CLI Tools Design
    Shintaro Kaneko - @kaneshin / גࣜձࣾΤ΢ϨΧ
    !1

    View Slide

  2. !2
    ࣗݾ঺հ
    ໊લ ۚࢠ৻ଠ࿠ 4IJOUBSP,BOFLP

    UXJUUFSDPNLBOFTIJO
    HJUIVCDPNLBOFTIJO
    ໾৬ औక໾$50
    ུྺ ೥ɿ౦ژཧՊେֶཧֶ෦ଔۀ
    ೥ɿ૊ࠐܥاۀ΁ೖࣾ
    ೥ɿגࣜձࣾΤ΢ϨΧ΁ೖࣾ
    ೥ɿಉࣾࣥߦ໾һ$50ब೚
    ೥ɿಉࣾऔక໾$50ब೚
    ಛٕ ৬छɿΤϯδχΞϦϯά
    ɺϚωδϝϯτɺ඼࣭อূ
    ٕज़ɿ$ɺ(Pɺ1)1ɺ($1ɺ"84
    ਺ֶɿ࠷దԽཧ࿦ɺઢܗʗඇઢܗܭը๏

    View Slide

  3. !3
    (PݴޠΒ͘͠(PίʔυΛ
    ࣮૷͢ΔͨΊͷख๏ͱࢥ૝
    IUUQTLBOFTIJOCPPUIQN

    View Slide

  4. !4
    (PݴޠΒ͘͠(PίʔυΛ
    ࣮૷͢ΔͨΊͷख๏ͱࢥ૝
    IUUQTLBOFTIJOCPPUIQN
    ຊ೔࿩͢͜ͱ͸͜ͷຊʹେମॻ͍ͯ͋Γ·͢

    View Slide

  5. Do you have experience of creating

    Command Line Tools?
    !5

    View Slide

  6. We absolutely need to know

    The CLI Design
    for publishing a great library
    !6

    View Slide

  7. Premature optimization is
    the root of all evil.
    We should forget about small efficiencies, say about 97% of the time:
    premature optimization is the root of all evil.
    Yet we should not pass up our opportunities in that critical 3%.
    - Donald Knuth

    View Slide

  8. UNIX Philosophy - Doug McIlroy
    This is the Unix philosophy:
    1. Write programs that do one thing and do it well.
    2. Write programs to work together.
    3. Write programs to handle text streams, because that is a universal
    interface.
    !8

    View Slide

  9. UNIX Philosophy - Mike Gancarz
    1. Small is beautiful.
    2. Make each program do one thing well.
    3. Build a prototype as soon as possible.
    4. Choose portability over efficiency.
    5. Store data in flat text files.
    6. Use software leverage to your advantage.
    7. Use shell scripts to increase leverage and portability.
    8. Avoid captive user interfaces.
    9. Make every program a filter.
    !9

    View Slide

  10. Go is based on the philosophy
    !10

    View Slide

  11. Command Line Interface
    !11
    $ exe [GLOBAL OPTIONS]... \
    [] [COMMAND OPTIONS]... [...]
    $ git --git-dir=/path/to/repo/.git \
    log --oneline -p origin/master
    • https://github.com/eure/kamimai

    View Slide

  12. View Slide