[HN Gopher] Techniques I Use to Create a Great User Experience f...
___________________________________________________________________
Techniques I Use to Create a Great User Experience for Shell
Scripts
Author : hundredwatt
Score : 28 points
Date : 2024-09-11 16:29 UTC (2 days ago)
(HTM) web link (nochlin.com)
(TXT) w3m dump (nochlin.com)
| mkmk wrote:
| I don't remember where I got it, but I have a simple
| implementation of a command-line spinner that I use keyboard
| shortcuts to add to most scripts. Has been a huge quality of life
| improvement but I wish I could just as seamlessly drop in a
| progress bar (of course, knowing how far along you are is more
| complex than knowing you're still chugging along).
| hipjiveguy wrote:
| can you share it?
| millzlane wrote:
| Not OP but I have used this one with success.
|
| https://stackoverflow.com/questions/12498304/using-bash-
| to-d...
| denvaar wrote:
| I'd add that if you're going to use color, then you should do the
| appropriate checks for determining if STDOUT isatty
| zdw wrote:
| Or $NO_COLOR, per https://no-color.org
| bfung wrote:
| Only one that's shell specific is 4. The rest can be applied any
| code written. Good work!
| kemitche wrote:
| Even 4 can be generalized to "be deliberate about what you do
| with a failed function call (etc) - does it exit the command?
| Log/print an error and continue? Get silently ignored?
| Handled?"
| Rzor wrote:
| Nicely done. I love everything about this.
| fragmede wrote:
| Definitely don't check that a variable is non-empty before
| running rm -rf ${VAR}/*
|
| That's typically a great experience for shell scripts!
| teroshan wrote:
| It happens to the best of us
|
| https://github.com/ValveSoftware/steam-for-linux/issues/3671
| jiggawatts wrote:
| Every time I see a "good" bash script it reminds me of how
| incredibly primitive every shell is other than PowerShell.
|
| Validating parameters - a built in declarative feature! E.g.:
| ValidateNotNullOrEmpty.
|
| Showing progress -- also built in, and _doesn't_ pollute the
| output stream so you can process returned text AND see progress
| at the same time. (Write-Progress)
|
| Error handling -- Try { } Catch { } Finally { } works just like
| with proper programming languages.
|
| Platform specific -- PowerShell doesn't rely on a huge collection
| of non-standard CLI tools for essential functionality. It has
| built-in portable commands for sorting, filtering, format
| conversions, and many more. Works the same on Linux and Windows.
|
| Etc...
|
| PS: Another super power that bash users aren't even aware they're
| missing out on is that PowerShell can be embedded into a process
| as a library (not an external process!!) and used to build an
| entire GUI that just wraps the CLI commands. This works because
| the inputs and outputs are strongly typed objects so you can bind
| UI controls to them trivially. It can also define custom virtual
| file systems with arbitrary capabilities so you can bind tree
| navigation controls to your services or whatever. You can "cd"
| into IIS, Exchange, and SQL and navigate them like they're a
| drive. Try that with bash!
| richbell wrote:
| I am Microsoft hater. I cannot stand Windows and only use
| Linux.
|
| PowerShell blows bash out of the water. I love it.
| watmough wrote:
| [delayed]
___________________________________________________________________
(page generated 2024-09-13 23:00 UTC)