glamline

module
v0.0.0-...-92817f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2022 License: MIT

README

Glamorous command line apps

Lightning talk, Martin Czygan, Leipzig Gophers #28, 2022-06-21 19:00 CEST

Social Text Club

But at its core, Unix has a social architecture -- [...]

...

What we wanted to preserve was not just a good environment in which to do programming, but a system around which a fellowship could form. We knew from experience that the essence of communal computing, as supplied by remote-access, time-shared machines, is not just to type programs into a terminal instead of a keypunch, but to encourage close communication. -- The evolution of the Unix time-sharing system, (1979) (fatcat)

Command Line Tools Renaissance

Random voices from the internet (2022-01-23)

I love the general renaissance of terminal UI tools we are seeing in the last few years. I can't quite put my finger on what I like about it so much.

[...] I can. Doesn't require a 1.5GB build directory to make a 500MB binary that uses 3GB of RAM to display a chat client/music player/etc.

There is a certain aura of efficiency around tools which fit into a 24x80 grid.

Glow Markdown Reader

Simply pleasant.

Charm and Universe

Charm builds cli support tools, OSS company; Changelog 481, ...

A dozen plus open source projects:

  • bubbletea tui library
  • wish ssh middleware
  • ...

ELM architecture

  • Model-View-Update
  • A basic model (data)
  • A view function that renders the model
  • An Update callback with events (keys, mouse, ...) that returns an updated model

More Apps

Stock Ticker
$ ticker --show-fundamentals -w META,GOOG,AMZN,MSFT,AAPL,NVDA

Love it.

Mergestat

Actually, is it true that 80% of the changes to a project are made in 20% of the files? Let's run some SQL over a git repository ...

$ cat authors.sql
SELECT author_name, count(*)
FROM commits -- replace repo
WHERE parents < 2 -- ignore merge commits
GROUP BY author_name ORDER BY count(*) DESC
LIMIT 20

That's similar to what git summary emits:

$ cat authors.sql | \
    mergestat -r ~/code/rclone/rclone/ -f tsv-noheader | \
    column -ts $'\t'

Nick Craig-Wood       4152
albertony             165
Ivan Andreev          130
Fabian Möller         114
buengese              66
Stefan Breunig        51
remusb                41
klauspost             29
Cnly                  29
Chaitanya Bankanhal   22
edwardxml             21
Tim Gallant           21
Gary Kim              21
ishuah                20
Klaus Post            20
Aleksandar Jankovic   20
Alex Chen             19
Martin Michlmayr      18
Dan Walters           18
Anagh Kumar Baranwal  17

A more complex query; most modified files in a repo (in the past year):

-- top 20 files changed most frequently in the past year
SELECT file_path, COUNT(*)
FROM commits('/home/tir/code/rclone/rclone'), stats('/home/tir/code/rclone/rclone', commits.hash)
WHERE
commits.author_when > DATE('now', '-12 month')
AND commits.parents < 2 -- ignore merge commits
GROUP  BY file_path
ORDER  BY COUNT(*) DESC
LIMIT  20

It takes a few seconds to calculate.

$ mergestat -f tsv < modified.sql | column -ts $'\t'
file_path                         COUNT(*)
docs/content/authors.md           70
backend/s3/s3.go                  18
docs/content/s3.md                16
docs/content/docs.md              15
go.mod                            13
backend/sftp/sftp.go              13
go.sum                            12
docs/content/jottacloud.md        12
fstest/test_all/config.yaml       11
fs/operations/operations.go       11
docs/content/drive.md             11
backend/azureblob/azureblob.go    11
backend/ftp/ftp.go                10
backend/box/box.go                10
fs/operations/operations_test.go  9
docs/content/ftp.md               9
docs/content/flags.md             9
docs/content/crypt.md             9
backend/onedrive/onedrive.go      9
backend/jottacloud/jottacloud.go  9

Back to our original question (using rclone repo):

  • commit last year
$ git log --pretty=format:"%H" --since 1.year.ago | wc -l
712
  • commits in the top 20 most touched files
$ mergestat -f tsv-noheader < modified.sql | \
    column -ts $'\t'  |
    awk '{print $2}' |
    paste -sd+ |
    bc -l
287

Total number of files in the repo: 2087. So 40% of the commits happen in less than 1% of the files (approximately).

Go Test Coverage Explorer (gocovsh)
$ go test -cover -coverprofile coverage.out
$ gocovsh

Task Timer
Presentations in your terminal

Draw

PS. My two year old found her first bug! (panic, when draw starts in tmux, probably window size is a bit off)

Catalog

OPAC in 115 lines of code.

$ go run opac/main.go

Confetty

Thanks for your attention!

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL