3 ms·
Just curious how you decide the line between what is handled by ShutIt and what's handled in the shell? For example, from the example on the home page: # En
by emilong 10y ago
Just curious how you decide the line between what is handled by ShutIt and what's handled in the shell?
For example, from the example on the home page:
# Ensure git is installed. This handles different distros gracefully.
shutit.install('git')
Awesome and very powerful abstraction! Vs the next lines...
# If the directory does not exist, we create it
if not shutit.file_exists('/opt/shutit',directory=True):
shutit.send('mkdir /opt/shutit')
Why not just:
shutit.send('mkdir -p /opt/shutit')
There are a few other examples where I was wondering how you decided to do some operations in ShutIt vs delegating to shell. In fact, some entire examples look simpler to me in shell that you could just send. Does using the ShutIt native commands make things more testable?
- zwischenzug 10y agoThat's just an illustration, not 'ideal' code. Of course mkdir -p serves the same purpose; the point is to show the 'file_exists' function. Mostly it's where using the shell would be painful. Do you have other specific examples?
- emilong 10y agoJust some similar stuff in the asciinema, but I'm thinking that's also just for illustration. Thanks for the clarification!
- zwischenzug 10y agoPleasure. BTW 'install' is really useful, eg here for my home server setup: https://github.com/ianmiell/shutit-home-server/blob/master/Shutitfile https://github.com/ianmiell/shutit-home-server/blob/master/S... so I can port to Centos from Ubuntu pretty easily. PS That's an example of a ShutItFile, which is still a WIP.
- mrb 10y agoI am a firm believer that example code that serves as a reference should illustrate the absolute best practices. "mkdir -p" is the best practice to create a dir that may or may not already exist, therefore this is a bad example (you are teaching some devs who don't know "mkdir -p" a bad practice). If you want to demonstrate the file_exists function, pick a better example. This is the same reason why I dislike, for example, seeing the documentation of a library showing how to perform actions X, Y, and Z, but a footnote says "by the way, there is no error checking in this example". Well then, why use this code as an example? Anyway, sorry for the rant. ShutIt does seem interesting :)
- zwischenzug 10y agoI know what you mean, but I couldn't think of a better example that would not have involved explaining something else that would have distracted from the point. I wasn't comfortable doing it, but at the same time, couldn't think of anything better. Actually, I have similar problems when teaching - I'm writing a git course at the moment, and it's hard to illustrate concepts in a realistic way without hopelessly artificial repos.
- rickycook 10y agothere's another file_exists for the git directory that seems to be an even more complete example :)