From 1f689fd039533801842ae241671f2437ddbe0044 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Thu, 7 Mar 2024 15:17:29 -0500 Subject: Copy old files and update build.sh to generate it all! This is a huge messy commit but :) sue me. I'm not at work I can do git badly for once! --- ...call-what-couldve-been-a-command-line-tool.html | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 posts/remember-recall-what-couldve-been-a-command-line-tool.html (limited to 'posts/remember-recall-what-couldve-been-a-command-line-tool.html') diff --git a/posts/remember-recall-what-couldve-been-a-command-line-tool.html b/posts/remember-recall-what-couldve-been-a-command-line-tool.html new file mode 100644 index 0000000..b9ede49 --- /dev/null +++ b/posts/remember-recall-what-couldve-been-a-command-line-tool.html @@ -0,0 +1,50 @@ + +--post-date: 2020-02-16 +--type: blog +
+

remember/recall - what could've been a command line tool

+

During a meeting at work when I realized I often forget useful + commands. So I had the bright idea to create a command line tool that + would basically append a file with the command you wanted to remember + that you could search over later if you wanted to recall a certain + command. I figured I could it could just be a simple bash script that + recalls your bash-history and appends it to a file, all things that are + incredibly easy to do... or so I thought.

+

Look before you leap

+

This article is a reminder to myself to test the core functionality + first, before decorating your program/script with all those bells and + whistles. While I did learn a lot in the process it is always a good to + check the basics first.

+

What went right

+

I actually ended up learning a lot during the development of the + (never finished) tool. I had never used getopts inside a + script before, which turned out to be extremely intuitive. That was all + that went right...

+

What went wrong

+

Literally, everything else that could've went wrong did. The + "project" was a single bash script roughly 160 lines long + before I found out it wouldn't work. It was a series of flags that + enabled actions that called functions, some of which ended the script + either successfully or not. It wasn't necessarily a mess to read (I + tried to make it that every function ended up in an exit so I knew if I + entered I would need to assume it terminated) but it was hard to follow + when writing. I tried to allow it so you could default an action to make + the CLI intuitive which lead to a messy set of if/elses and switch + cases.

+

You can't access un-committed bash history

+

History command in a bash shell commits the history at the end of the + session. This makes sense once you know this, there are a lot of reasons + saving the commands to file after every execution is probably not the + best idea. However, it can be enabled with a flag when you enable a shell + session. But I didn't want to build a tool that required me to + remember I had to add something to my bash_profile before it would work. + I wanted something I could just copy onto a new machine and have access + to its functionality.

+

Lesson learned

+

While developing a tool to help me remember things, I learned + something I cannot forget: Test the core, simplest functionality first. + Before you do anything validate what you're trying to do will work. + Because after building all of these fancy bells and whistles, if it + can't do the basics, there is no point.

+
+ -- cgit v1.2.3-54-g00ecf