What Makes A Good Cli Tool | Prime Explains

  Рет қаралды 57,082

ThePrimeTime

ThePrimeTime

9 ай бұрын

Recorded live on twitch, GET IN
/ theprimeagen
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
Have something for me to read or react to?: / theprimeagenreact
Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
turso.tech/deeznuts

Пікірлер: 156
@Anteksanteri
@Anteksanteri 9 ай бұрын
It's weird how many developers don't even know how to use the command line.
@CottidaeSEA
@CottidaeSEA 9 ай бұрын
It's nice to be among developers who don't know how to use them, because I can basically be a magician who gets information out of seemingly nowhere in an instant. To those who know, I just used grep.
@Beefster09
@Beefster09 9 ай бұрын
it's forgivable coming from a junior dev, but I facepalm in shock when I see it coming from someone who has been in the industry for 20+ years
@ardnys35
@ardnys35 9 ай бұрын
we have been spoiled with fancy graphics and it only gets more and more unfamiliar. plus no one really teaches it.
@CottidaeSEA
@CottidaeSEA 9 ай бұрын
​@@ardnys35 I think some people also find it daunting since CLI tools are quite volatile. They do exactly what you tell them to do without questioning anything. That's also why they are great (besides being fast) but you can mess things up if you do the wrong thing. Then again, people seem to be less afraid of SQL despite being able to nuke an entire table by forgetting to add WHERE.
@Euphorya
@Euphorya 9 ай бұрын
I die a little inside every time my manager says "that's nice, but does it have a GUI?"
@livingcodex9878
@livingcodex9878 9 ай бұрын
Well that was an epic nugget of knowledge. Can we get more of that please?
@FractalWanderer
@FractalWanderer 9 ай бұрын
Agreed!
@hoimar8710
@hoimar8710 9 ай бұрын
Please do the frontend masters course for writing good unixoid CLI tools! Including golden shower tests!
@cg219
@cg219 9 ай бұрын
I want to put in my vote for the Frontend Masters course on this. Thanks!
@fennecbesixdouze1794
@fennecbesixdouze1794 9 ай бұрын
@3:25 You can accomplish the same thing with shell redirections, or *gasp* the dreaded cat piping. All tools should start with stdin and stdout. If you really wanna build in file handling fine, but you don't have to.
@joaomacedo673
@joaomacedo673 9 ай бұрын
Yeah. Moreover, when I heard him say that using files functionality support is cool for integration tests I was wondering "well, but you are not testing stdin input that way". And with pipe redirection you actually can.
@luigidabro
@luigidabro 3 ай бұрын
Never underestimating the power of piping. But specifying stdin to be a file can be useful. On cmd or powershell 1.0, piping removes all non-ascii characters.
@Jmcgee1125
@Jmcgee1125 9 ай бұрын
It's called tee because it makes a T. Data flows across the top of the T (from stdin to stdout), but also gets duplicated out the bottom (to a file). Super useful, and not just for :w !sudo tee %
@xenio8736
@xenio8736 9 ай бұрын
wait wha's the point of :w !sudo tee % ?
@Jmcgee1125
@Jmcgee1125 9 ай бұрын
Save a root-protected file if you opened vim as a normal user.
@sempiternal_futility
@sempiternal_futility 9 ай бұрын
very good explanation actually
@theodorealenas3171
@theodorealenas3171 9 ай бұрын
Wait, :w can write into the stdin of a shell command?
@Jmcgee1125
@Jmcgee1125 9 ай бұрын
@@theodorealenas3171 It can! It can even do it for range writes (i.e. writing from visual line mode), if you only want to send a segment.
@thingsiplay
@thingsiplay 9 ай бұрын
The Unix philosophy is like functional programming.
@simonfarre4907
@simonfarre4907 9 ай бұрын
It's an apt description, indeed of the Unix philosophy.
@bitti1975
@bitti1975 9 ай бұрын
If I'd categorize it, I'd file it under 'Dataflow programming' but that's a more or less orthogonal concept.
@ripplecutter233
@ripplecutter233 9 ай бұрын
the issue isn't the pipelines, it's all the basic commands you have to learn. takes time to remember them all (the basic ones). but once you know em then yeah it's pretty much functional programming
@simonfarre4907
@simonfarre4907 9 ай бұрын
​@@bitti1975 I think you're misunderstanding / misusing the term orthogonal. Because "dataflow programming" is most certainly a core tenet of FP. Clear input and output. Referential transparency and all. These are not unrelated. But I guess you could say it's a simplified description of FP, instead. That being said, I don't think anybody had FP in mind when the Unix Philosophy was "created" as it were.
@fennecbesixdouze1794
@fennecbesixdouze1794 9 ай бұрын
Yep. UNIX's shell redirects and pipes can be derived formally as an I/O monad. It's not a matter of opinion: it's exactly, formally, provably like functional programming
@kc3vv
@kc3vv 9 ай бұрын
Thanks to you I recently came to enjoy gnu parallels to parallelise some build scripts.
@notapplicable7292
@notapplicable7292 9 ай бұрын
This is really useful as someone who's recently working on CLI tools.
@aus10d
@aus10d 9 ай бұрын
very helpful tips. thank you prime!
@Omikronik
@Omikronik 9 ай бұрын
this is the kind of advice I love mr prime for.
@JordanShurmer
@JordanShurmer 9 ай бұрын
Thanks for sharing this. Imagine reading this tip as an article when you can watch a video instead... oh man
@barrykp
@barrykp 9 ай бұрын
Would love a course on tooling!
@0dsteel
@0dsteel 9 ай бұрын
This casual 4 and a half minute vod has more useful information than hours long tutorials
@Jason_Kang
@Jason_Kang 9 ай бұрын
PLEASE do a course on writing dev tools! 🙏🙏🙏
@nixoncode
@nixoncode 9 ай бұрын
all great developers understand how unix works
@abdelazizlaissaoui9079
@abdelazizlaissaoui9079 4 ай бұрын
Where to learn more about those things???
@sorosborcsi
@sorosborcsi 9 ай бұрын
Your best video so far ⚒️ thanks
@nomomcarver
@nomomcarver 9 ай бұрын
good advice
@AloisMahdal
@AloisMahdal 9 ай бұрын
I believe the right way to call tee(1) is `tee hee`.
@dealloc
@dealloc 9 ай бұрын
POSIX compliance is a must.
@peteradam4740
@peteradam4740 9 ай бұрын
Please do that course :)
@marlo3898
@marlo3898 9 ай бұрын
The good old Golden Shower Test
@pbnjdev
@pbnjdev 9 ай бұрын
"Command-line Tools can be 235x Faster than your Hadoop Cluster" -Adam Drake
@McHorsesCreations
@McHorsesCreations 9 ай бұрын
He didn’t said “-agen” 😭😭😭
@laughingvampire7555
@laughingvampire7555 9 ай бұрын
gnu parallel is used a lot in bioinformatics or other scientific computing areas, they make a script in python or perl and then gnu parallel.
@fuutek9171
@fuutek9171 9 ай бұрын
please do a tips n tricks for common cli tools like grep
@JoaoJGabriel
@JoaoJGabriel 9 ай бұрын
I'm glad this became a KZbin video-AGEN
@eloniusz
@eloniusz 9 ай бұрын
C++ has two stream outputing to stderr "std::cerr" and "std::clog". The latter one really makes it clear that this is where the logs should go to (and not to "std::cout").
@gamemoves2415
@gamemoves2415 9 ай бұрын
Please do the course. Would be very happy
@ersstuff
@ersstuff 9 ай бұрын
Amazing diagram!
@codedbyshoe
@codedbyshoe 9 ай бұрын
We need a "last cli class you'll ever need"
@ripplecutter233
@ripplecutter233 9 ай бұрын
a good cli tool can easily integrate into a pipeline.
@NicolasRuizX
@NicolasRuizX 9 ай бұрын
Please do the course!!!
@mvargasmoran
@mvargasmoran 9 ай бұрын
You said Golden Shower, I google that, it was nothing about software testing. 🥺
@benjaminemori9089
@benjaminemori9089 9 ай бұрын
Watching you alone brings me a whole level of inner joy!😂
@markmcdonnell
@markmcdonnell 9 ай бұрын
tee has been my secret sauce since forever
@Dev-Siri
@Dev-Siri 9 ай бұрын
My comment is, I cannot believe prime made this a youtube video.
@Forquare
@Forquare 3 күн бұрын
Please can we normalise man pages with CLI tools - I honestly don't think a tool should reach v1 without a man page. I don't want to figure out what your help flags are and have a ton of scollback maybe printed to stdout or maybe to stderr, I just want to write `man ` and use my favourite $PAGER to browse the options, example usage, etc.
@chrisE815
@chrisE815 9 ай бұрын
Lithium batteries, interchangable heads, pulsing and vibration functions, ....Oh sorry I misread the video title .
@trapexit
@trapexit 9 ай бұрын
re: tee... yes! or at least write a script which writes data out if not already stored. Too often people try to consume and process data in the same loop and it puts unnecessary strain on the data source and complicates debugging. Just write it out somewhere and use that. I wouldn't call it a "break point" but I understand what is meant by it. It's literally a T... like a pipe T... 1 input and 2 outputs of the same data. The syscall does the same.
@dtomvan
@dtomvan 9 ай бұрын
damn, i knew about tee but never thought of it as a "pipe-breakpoint" I always have to refetch a big pipeline 😔
@ShadowKestrel
@ShadowKestrel 9 ай бұрын
I'm a little confused on the inclusion of optional file reading/writing - would it not be simpler to only support stdio at the program level, then use angle brackets or cat/tee for if you want files? To me it seems that would also follow "do one thing and do it well", although with how often I see the pattern it seems more likely I'm just missing something here
@kuhluhOG
@kuhluhOG 9 ай бұрын
speed/throughput just go and test the difference of: cat some_file | grep some_regex vs grep some_regex some_file
@ShadowKestrel
@ShadowKestrel 9 ай бұрын
@@kuhluhOG that's a useless use of cat - of course it's less performant than redirections. I actually see slightly improved performance with redirections instead of file argument, although it's the difference between averaging 1.21s and 1.23s (maybe zsh caching, maybe some reduced syscalls, don't really know why)
@CramBL
@CramBL 9 ай бұрын
@@ShadowKestrel point still stands. Maybe you want to run something multiple times on some compressed data, you could use lz4 -d -c | debug-tool or you could decompress to a file first and then save decompression overhead, piping IO overhead (which is very significant), and you enable some really powerful optimizations such as memory mapping or pre-allocation based on file size etc.
@trapexit
@trapexit 9 ай бұрын
Because redirection is a function of the shell and not all usage of the tool is within the shell.
@Drummerx04
@Drummerx04 9 ай бұрын
It's useful for a few reasons. Off the top of my head, you can specify multiple input files at once, you give explicit options for anyone using your tool in a script, and the tool would likely behave better when not being launched from a full shell environment.
@Howtheheckarehandleswit
@Howtheheckarehandleswit 9 ай бұрын
I'm always torn on the file escapes thing. Because it does kinda feel like it violates the UNIX philosophy to integrate that into my program when I could always replace "foo --input ./bar --output ./baz" with "cat ./bar | foo > ./baz", but that does also make it kind of a pain to use on files
@joshix833
@joshix833 9 ай бұрын
Cat is for concatinating not for reading single files. foo < ./bar > ./baz
@Howtheheckarehandleswit
@Howtheheckarehandleswit 9 ай бұрын
@@joshix833 No one ever bothered to teach me the
@theodorealenas3171
@theodorealenas3171 9 ай бұрын
​@@Howtheheckarehandleswitoof. I felt that one, I started using it after a year of using Linux, or more
@Luisya14
@Luisya14 9 ай бұрын
What do I need to do to end up working on stuff like this? I'm really bored at my current job (make one webapp finish next, do it super fast so the project is cheap)
@chrissaltmarsh6777
@chrissaltmarsh6777 9 ай бұрын
To learn this, fire up a unix machine from, uh 35 years ago and do some work. Those ideas are utter gold. And have short options. '-v' is a hell of a lot quicker on a 2400 baud VT100 than '--version' (But I am ancient)
@Keversez
@Keversez 9 ай бұрын
make a course on this homie
@adjbutler
@adjbutler 9 ай бұрын
please do the 'good tools' course... I would pay big dollars for you to do it!!!!
@ItaloPenna
@ItaloPenna 5 ай бұрын
A good CLI tool also must return a signal. Returning a good defined integer is awesome . Sometimes you don't give a 5hit about strings. ( Windows programmers nowadays have no clue about this.)
@seg_fault_jim
@seg_fault_jim 9 ай бұрын
@primetime do a video showing this in code - that would help people understand
@EivindGussiasLkseth
@EivindGussiasLkseth 9 ай бұрын
Do you have a sample repo to look at?
@Anton_Sh.
@Anton_Sh. 5 ай бұрын
What is that drawing app he is using?
@eqprog
@eqprog 9 ай бұрын
Inversed whiteboard
@gabumon9210
@gabumon9210 9 ай бұрын
hey i work as a web dev with 2 years experience. but i feel, im so lack about how actually that thing work or how to make something other than a web server or web client. maybe because i started learning programming trying to build a website. primeagen video appear on my youtube home, and i think he is what we called an engineer or a dev not just 'react dev' or etc. What step should i go to learning this kind of thing ? i mean like memory, gc, and many more i hope you know what i mean I hope anyone here who have lot of experience as 'software engineer' can tell me what should i learn first and the learning path.
@abcdefg-nu4xj
@abcdefg-nu4xj 9 ай бұрын
It all comes down to understanding the fundamentals, understanding c, assembly, memory management, compilers and operating systems, even some hardware and cpu architectures, can give you insights about how your browser and JS engine works (both implemented in c++ utilizing many fundamental concepts mentioned above) that the absolute majority of ‘exclusively web devs’ will never try to begin to understand. It can enhance the quality of your code, broaden the things you can do and make it easier and faster for you to learn new technologies. Those who took a CS degree had to go through a few semesters of learning the fundamentals. Prime has a CS degree so he had to go through that too. However a CS degree is absolutely not mandatory to get a deep understanding of fundamentals since everything exists online
@gabumon9210
@gabumon9210 9 ай бұрын
@@abcdefg-nu4xj hey, thanks for the answer ! I think you are right, i lack everything about computer scince since i learn programming not from cs degree I search on youtube and harvard make a video about CS with 24h long. I hope it can help me to learn some computer science. Thank you for your answer 😄
@abcdefg-nu4xj
@abcdefg-nu4xj 9 ай бұрын
@@gabumon9210 i would suggest taking it one step at a time, dedicate a few days to learning c well, focusing on pointers and memory. Then maybe try and implement a few data structures (dynamic array, hashtable, red-black tree) and algorithms from scratch with c, then you can go a little lower level and learn assembly , focus on how your C code translates to assembly, this is a great chance to learn about CPU architecture and get a deeper knowledge about memory. The next thing from here is to learn about operating systems, namely linux. First learn how to interact with the OS as a “user” with syscalls to spawn threads, manage memory and IO. Then, with your knowledge of c, data structures and sssembly you can go deeper and learn how central parts of the OS are implemented, how it manages threads, I/O , memory, etc. Each step might take you a few weeks or months to get right but once you’re done you will have a strong foundation to learn about things that build on those fundamentals like networking, compilers, virtual machines, web browsers, etc Anything that interests you Your learning sources should be yt videos, free (or paid) courses and books
@xybersurfer
@xybersurfer 9 ай бұрын
but where do status updates fit into this?
@TorkilZachariassenTZNG
@TorkilZachariassenTZNG 9 ай бұрын
Jźzz ... programs read stdin/file and output to stdout/file and stderr. That's what the professor told is in 1982 teaching Pascal and Fortran simultaneously
@Tetsomina
@Tetsomina 9 ай бұрын
Someone send this man a weebo tablet for these excalidraw moments 😂
@mvargasmoran
@mvargasmoran 9 ай бұрын
Teez Nutz
@TheNewton
@TheNewton 9 ай бұрын
what kind of football play is that? 0:22
@uuu12343
@uuu12343 9 ай бұрын
I use CLI utilities like there's no believing
@SimGunther
@SimGunther 9 ай бұрын
If only there was a language that outlined CLI commands like this drawing... bash/zsh/csh/fish do not count in this regard for those wondering
@kj_sh604
@kj_sh604 9 ай бұрын
pipe is the only way to pipe
@nomadswe
@nomadswe 9 ай бұрын
Windows Terminal ftw
@bicube7529
@bicube7529 9 ай бұрын
ok, i'm too junior to understand, need some code examples. anyone konws a github repo that shows what he said?
@yaksher
@yaksher 9 ай бұрын
Why put in all the effort for file inputs and outputs? Isn't that what redirects are for? And like, sure, redirects don't support multiple files for standard in, but you can just use cat for that, no?
@joshix833
@joshix833 9 ай бұрын
Most of the time yes. But e.g. grep needs file arguments to be able to show source files and lines.
@pineberryfox
@pineberryfox 9 ай бұрын
if you only care about using a single file, check the args and freopen the standard streams when appropriate. then you get to pretend like you're only using the standard streams, but you're not inconveniencing your users for example, with xargs, you can have a list of files to operate on, one-per line, and say "
@billeterk
@billeterk 9 ай бұрын
Sometimes you do need to seek though
@yaksher
@yaksher 9 ай бұрын
​@@joshix833 Sure, but that's an exception; that's not a reason to bake it into most tools
@yaksher
@yaksher 9 ай бұрын
@@pineberryfox I suppose it's slightly more convenient with xargs but can't you also just do a cat with xargs? But fair enough
@barutaji
@barutaji 9 ай бұрын
"what is golden shower?" (Bolsonaro, 2020)
@Cammymoop
@Cammymoop 9 ай бұрын
I want to write a better cli calculator but i know i shouldn't
@user-kc8uh9ve4j
@user-kc8uh9ve4j 9 ай бұрын
Personally I use python for calculations in the cmd just the standard repl/IPython
@daleryanaldover6545
@daleryanaldover6545 9 ай бұрын
Most languages (php, ruby, python) or frameworks (node, laravel artisan) have interactive shells, just input an expression and voila calculation complete
@Cammymoop
@Cammymoop 9 ай бұрын
@@user-kc8uh9ve4j I use the python repl too, I just have the craving to make something with a better interface. auto implied last result, proper juxtaposition multiply, lists and automatic mapping of scalar functions, cli option to output a cleaned version of last session, etc Which is why I definitely shouldn't, I don't think I actually have that kind of time
@billeterk
@billeterk 9 ай бұрын
Depends on your metrics for good but qalc is pretty awesome for a semi reliable DWIM calculator
@Cammymoop
@Cammymoop 9 ай бұрын
@@billeterk That does look pretty darn good, thanks
@adamgrey268
@adamgrey268 9 ай бұрын
lessssgoooooooooo!
@Swifter101
@Swifter101 9 ай бұрын
you look a gta character
@joaovmlsilva3509
@joaovmlsilva3509 9 ай бұрын
I feel like I'm missing 90% of the context here.
@thomas-hall
@thomas-hall 9 ай бұрын
File in/out is just duplicating stdin/out
@DarrenJohn10X
@DarrenJohn10X 9 ай бұрын
git push faster way of doing things into brain MERGE CONFLICT
@kollpotato
@kollpotato 9 ай бұрын
potato
@eduardocosta9078
@eduardocosta9078 9 ай бұрын
Just dropping a comment to be the first.
@zeyadkenawi8268
@zeyadkenawi8268 9 ай бұрын
parallel sucks I use xargs
@yusufcansert9276
@yusufcansert9276 9 ай бұрын
You are only talking, code once ıf you can
@tropicaldog430
@tropicaldog430 9 ай бұрын
🥴
@deistormmods
@deistormmods 9 ай бұрын
those are most of his videos. he doesn't really do programming and if he does, he's constantly talking to the chat. its a different type of channel and it isn't for everyone.
@c0ldfury
@c0ldfury 9 ай бұрын
this is wrong on so many levels. when processing a file, the stdin and stdout IS the file stream. there's no separate channel for files.
@4444kik
@4444kik 9 ай бұрын
Real talk, how many developers watching this video who have a job didn't know and use parallel and tee at least once already (not necessarily together)? As a Linux guy I know my command line like the back of my hand, but not every developer is a Linux guy. I know 2 other developers personally and one of them is really not familiar with it at all and the other knows enough to get the job done but hates using it, or so he tells me. I'm curious what the demographic here is like.
The Most Amazing Software Ever Created
20:02
ThePrimeTime
Рет қаралды 287 М.
This CLI Tool is AMAZING | Prime Reacts
11:59
ThePrimeTime
Рет қаралды 77 М.
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 9 МЛН
She ruined my dominos! 😭 Cool train tool helps me #gadget
00:40
Go Gizmo!
Рет қаралды 45 МЛН
Just try to use a cool gadget 😍
00:33
123 GO! SHORTS
Рет қаралды 66 МЛН
Prime Reacts:  Building a Startup in Rust; I won't do it again
17:23
ThePrimeTime
Рет қаралды 224 М.
Projects Every Programmer Should Try
16:58
ThePrimeTime
Рет қаралды 370 М.
Become a shell wizard in ~12 mins
12:25
CODE IS EVERYTHING
Рет қаралды 217 М.
Python Sucks And I LOVE It | Prime Reacts
15:43
ThePrimeTime
Рет қаралды 257 М.
10 AWESOME CLI TOOLS TO SUPERCHARGE YOUR WORKFLOWS
10:03
Adib Hanna
Рет қаралды 12 М.
7 Amazing CLI Tools You Need To Try
18:10
Josean Martinez
Рет қаралды 224 М.
AWS Fooled Devs & Sabotaged The Industry | Prime Reacts
21:47
ThePrimeTime
Рет қаралды 206 М.
Hack your brain with Obsidian.md
11:53
No Boilerplate
Рет қаралды 1,8 МЛН
Dependency Injection | Prime Reacts
28:34
ThePrimeTime
Рет қаралды 294 М.
keren sih #iphone #apple
0:16
kadangaruan
Рет қаралды 1,7 МЛН
Мечта Каждого Геймера
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,4 МЛН