Skip to main content

Nothing helps coder be more smarter & less dumber.

Project description

Nothing (not)

Nothing helps coders be more smarter, some cooler, less dumber, and much faster. not.

Take hold of the key 🔑 to gradual automation.

Installation

nothing-cli is very young, only an infant. 🐣

If you'd like to give it a try, it's available ion PyPi test.

pip install --index-url https://test.pypi.org/legacy/ nothing-cli

In part due to its youth, only Python 3.7 and above are supported. 😬

The command for interacting with the tool is not. Get the overview of its subcommands like so:

not --help

Get up and going by running:

not init

You should now have a sample Procedure available, aptly named nothing. Get an overview of what it does and where it lives with the describe subcommand:

not describe nothing

You can invoke it with the do subcommand:

not do nothing

You'll be walked through the Procedure for doing... nothing. Enjoy! Folks don't do enough nothing, in my opinion.

Inspo & Rationale

Once upon a time, we all read this article about "do-nothing scripting" by Dan Slimmon.

It's an incredible concept. I've personally wasted hours of my life trying to turn ever-more-complex aliases into shell functions. I've spent days attempting to automate scripts to do extremely infrequent –but highly toilsome– tasks that probably would not even have taken hours manually.

"Toil," as Slimmon terms it, sucks. We'll do anything to get away from it. Do-nothing scripts are a place to meet halfway: Nowhere near the cognitive overhead of writing an actual automation script, but more interactive and dynamic than pure documentation.

But, even logic-free & sugary sweet do-nothing scripts are written in the language of your choice can be fragile. Your stylistic decisions rot. There's no formality to creation or maintenance. Hardcoded strings sprinkled on off-the-cuff implementation. Suddenly, toil returns. Utility vanishes.

Realizing this as my team and my friends experimented more with the practice, I did the logical thing: I wrote an entire piece of software to automate the process of writing the code we write to prevent ourselves from writing too much code to automate stuff when we want to stop toiling and just write some freaking code.

It's a noble cause, I think. [Insert infrequent terrible process] always goes faster when you can just ask your teammate for that really specific command and copy-paste. Cut them some slack. Get the command from a terminal robot.

Pudding (The proof is in it)

Here is the original do-nothing script example from Slimmon

import sys

def wait_for_enter():
    raw_input("Press Enter to continue: ")

class CreateSSHKeypairStep(object):
    def run(self, context):
        print("Run:")
        print("   ssh-keygen -t rsa -f ~/{0}".format(context["username"]))
        wait_for_enter()

class GitCommitStep(object):
    def run(self, context):
        print("Copy ~/new_key.pub into the `user_keys` Git repository, then run:")
        print("    git commit {0}".format(context["username"]))
        print("    git push")
        wait_for_enter()

class WaitForBuildStep(object):
    build_url = "http://example.com/builds/user_keys"
    def run(self, context):
        print("Wait for the build job at {0} to finish".format(self.build_url))
        wait_for_enter()

class RetrieveUserEmailStep(object):
    dir_url = "http://example.com/directory"
    def run(self, context):
        print("Go to {0}".format(self.dir_url))
        print("Find the email address for user `{0}`".format(context["username"]))
        context["email"] = raw_input("Paste the email address and press enter: ")

class SendPrivateKeyStep(object):
    def run(self, context):
        print("Go to 1Password")
        print("Paste the contents of ~/new_key into a new document")
        print("Share the document with {0}".format(context["email"]))
        wait_for_enter()

if __name__ == "__main__":
    context = {"username": sys.argv[1]}
    procedure = [
        CreateSSHKeypairStep(),
        GitCommitStep(),
        WaitForBuildStep(),
        RetrieveUserEmailStep(),
        SendPrivateKeyStep(),
    ]
    for step in procedure:
        step.run(context)
    print("Done.")

Here it is translated to a nothing-cli Procedure:

---
title: Provision New User Account
description: Create and distribute an SSH key for a new user.
context:
  - username
  - build_url
  - dir_url
  - email: Copy the new user's email and paste here
steps: |-
  Run:
    ssh-keygen -t rsa -f ~/{username}

  Copy ~/new_key.pub into the `user_keys` Git repository, then run:
    git commit {username}
    git push

  Wait for the build job at {build_url} to finish:

  Go to 1Password
  Paste the contents of ~/new_key into a new document
  Share the document with {email}

I know it's impolite to talk about LOC, but the nothing-cli procedure version weighs in at 17 to the original 43 (excluding blank lines). The drastically improved readability and editability should speak for itself.

Things to Note

You'll notice that context is specified in 2 ways. The first three items are specified using "simple context," where the value is merely a yaml list item. The user is prompted for those values with a default phrase: Please provide a value for [variable name]. The last context item uses dictionary syntax, allowing the specification of a friendlier prompt.

Next, the funny looking |- next to steps specifies a block scalar. The very existence of this yaml feature was a great inspiration to create this tool in the first place. It functions as a sort of lawless playground for plain text, supporting:

  • Multiline text and indentation.
  • A clear visual delineation of content from configuration
  • The specification of each step as a paragraph, which is is both obvious to read and easy to edit.

It is worth mentioning, however, that the current version of nothing-cli is not able to replicate the original script exactly.

If you run them side-by-side, you'll see that the original uses hard-coded values for dir_url and build_url. Additionally, the user is prompted for email in the middle of the script, rather than at the end. These omissions are discussed in the Planned Features section.

Planned Features

The alpha version of nothing-cli was meant to be as focused as possible. For this reason, some mechanics of the original do-nothing script were omitted. They will be implemented, however. I very strongly welcome contributions from anyone who wants to help out with the growth of this tool. Please email me.

Priority Features

These features are high on the todo list.

Lazy Context

When using the original do-nothing script, the user is prompted in the middle of the run for a new context variable. In future versions of nothing-cli, this mechanic will be supported by "lazy context". The planned syntax is pretty straightforward.

context:
  - regular_context  # prompted at the beginning
  - __lazy_context  # prompted before the first reference

Lazy context will still support simple and complex syntax.

Presets

In order to set variables that the user will not be prompted for, a presets key will be added:

context:
  - user_wil_be_prompted_for_this
presets:
  - this_is_hardcoded: This is the value

Moonshot Features

The implementation of these features has not been considered far beyond daydreams.

Promptless Presets & Context

In an ideal world, users could specify context as usual:

---
# diet-review.yml
context:
  - favorite_food: What's your favorite thing to eat?

But then circumvent the prompt by running the Procedure like this:

not do diet-review --favorite-food 'french omelet'

Even more useful would be specifying a this for presets:

---
# secret-stuff.yml
presets:
  - secret_password

Specifying a preset with no value (as a plain yaml list item) would require the Procedure to be run with the value as a command-line option.

not do secret-stuff # refuses to run
not do secret-stuff --secret_password 'n3veR $h4re tHis--'

Chaining Procedures

For the composition-minded, it could be a boon to write small, related Procedures and have them run directly into each other, maybe even sharing context.

This could be specified at runtime:

not do proc-1 --chain proc-2 --chain proc-3

Or in the Procedure itself:

---
# use-chains.yml
title: Use chains
description: Demonstration of chain usage
context:
  - name
steps: |-
  Love yourself and your colleagues, {name}.

  Choose composition.
chain:
  to: review-chaining
  pass_context: yes

Conditional Chaining

We're getting absolutely crazy here, but adding several features could allow for supercharged chains:

---
# ci-stuff.yml
title: CI/CD Toil
description: Boring CI thing, one day you'll automate. But now now.
context:
  # add syntax for limited choice context
  - deploy_phase[dev/prod]: What kind of deploy are you doing?
chain:
   # use context to determine where chain
  - if:
      deploy_phase_is: dev  # name mangling 😵
      to: dev-deploy
  - if:
      deploy_phase_is: prod
      to: prod-deploy

This one is surely a moonshot but damn... I wanna do it 🤩

And more!

My head is full of ideas! Perhaps yours is too. If you believe in this tool, drop me a line, I'll be overjoyed and say nice things to you. 😸

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nothing-cli-0.0.post4.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

nothing_cli-0.0.post4-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file nothing-cli-0.0.post4.tar.gz.

File metadata

  • Download URL: nothing-cli-0.0.post4.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/18.7.0

File hashes

Hashes for nothing-cli-0.0.post4.tar.gz
Algorithm Hash digest
SHA256 0b76f5c549189b665ca6e0043bf8c9e90264e61ad245bbf5bc31e7893e76aae7
MD5 6caab8ba40d8205e514ec6191392abc2
BLAKE2b-256 84d876d9dd7464c7bc9795f56af93facac3fd262b76ba33c5154a4b614d367a3

See more details on using hashes here.

File details

Details for the file nothing_cli-0.0.post4-py3-none-any.whl.

File metadata

  • Download URL: nothing_cli-0.0.post4-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/18.7.0

File hashes

Hashes for nothing_cli-0.0.post4-py3-none-any.whl
Algorithm Hash digest
SHA256 8a50c7ef8c321bef1bed0d199d479c49a5a241bf1a368cfda81bbc313bad797c
MD5 84ee5cab7195ecb29878a0aa73548873
BLAKE2b-256 f35c7bf87aedbcdd467240d766c22f5a67a9ff5174a4da7304cbeef21100d6be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page