Giter Site home page Giter Site logo

run_ok's Introduction

Run, OK?

Run, OK? is a shell function to run a function or command with pretty output. It produces a Unicode checkmark or X if the shell supports it (we don't check the terminal, but terminals seem to be more likely to support it than shells), and an "OK!" or "ERROR" otherwise. They will be green, and red, respectively, assuming the terminal supports color and the palette being used has reasonable greenish and reddish colors in the right places.

It is expected to work in reasonably modern bash and dash. I will try to test occasionally on FreeBSD Bourne sh, but right now, I can't make FreeBSD run in Vagrant for more than a few seconds.

What's it look like?

run_ok demo

Usage

Source it, and call your long-running processes, using the run_ok function:

    . ./run_ok.sh
    
    # Where to log results
    log=/path/to/run.log
    
    run_ok "do --something --slow" "Doing something slow"

Currently there's only one obvious knob to twiddle in run_ok, which is the log file. It requires spinner to be installed in the parent directory (you can adjust that in the run_ok.sh source).

But, you can also override spinner option variables. See the spinner docs for what those are. The "WIDE" spinners are designed to work nicely with run_ok.

Compatibility

This one is really tricky, on a lot of fronts. Unicode, argument passing, fractional second sleep, etc. are all of questionable cross-platform availability. But, it works in my tests on the platforms and versions I need to support.

I am confident it works on reasonably modern bash and dash (where I test with every change). I am less confident of Bourne sh on FreeBSD.

Contributing

I welcome patches, as long as they don't break compatibility with bash and dash. I especially welcome patches that improve compatibiltiy across other shells, or make run_ok more resilient to odd input. (In particular, I don't know how to pass in a multi-expression command, e.g. with ; to separate commands, and would like to support that use case, though error capture would be particularly tricky).

run_ok's People

Contributors

swelljoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

run_ok's Issues

expect improvement

I have tested, English can be fully aligned
But if it is Chinese + English + spaces, it cannot be aligned

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.