Code Monkey home page Code Monkey logo

aqfr's Introduction

aqfr

Multipath command line piping.

Why?

To pipe commands not only as a single sequence, but across a more complex graph. Not a pipeline, but pipework.

How?

Run the aqfr command, passing one string for each command in the graph.

Begin each string with @<i>, where @ is simply the default tag and <i> the preferred identifier for the command. End each string with one of the following substrings:

  • the tag and identifier for each command to which the output should be passed, run together if more than one pair, e.g. @b@c to pass the output to the commands with the identifiers b and c
  • the default tag @ alone if the output is not to be passed

For example:

aqfr "@1 cmd... @2" "@2 cmd... @3@4" "@3 cmd... @4" "@4 cmd... @"

This passes the output from command 1 to command 2, the output from command 2 to commands 3 and 4, and the output from command 3 to command 4, the output of which is not passed on.

Alternatively, the commands can be read from a file (see Options below), for ease of storage and reuse and to avoid the need to quote.

Note

Be aware that aqfr generates and passes strings to the shell. As with any use of the shell, and any use of intermediary code invoking the shell, care should be taken. The aqfr source code should be reviewed before proceeding and any intended use of aqfr should first be tested in a context in which no harm can be done.

Script

The script can be run with the command ./aqfr while in the same directory, and from elsewhere using the pattern path/to/aqfr, by first making it executable, if not already, with chmod +x aqfr. Once executable, it can be run from any directory with aqfr by placing it in the '/bin' or '/usr/bin' directory.

The hashbang at the top of the file assumes the presence of Elixir.

Making changes

The src/ folder contains a Mix project, with the primary aqfr source file at src/lib/aqfr.ex. This setup allows the script to be developed and tested with the use of the Mix build tool.

The output file can be produced by running the shell script at src/get, which copies the primary file to the root directory, uncomments the final line and makes the output file executable, as well as copies the primary file version number to src/mix.exs.

Options

The following can be passed to aqfr:

  • --file / -f, to read commands from a named file, where the file contains one unquoted command per line, e.g. aqfr -f args.txt
  • --tags / -t, to identify a non-default tag, where used, e.g. aqfr -t TAG
  • --help / -h, to show usage then exit

Development plan

The following are possible next steps in the development of the code base. The general medium-term aim is a convenient command line multiplier with major use cases covered. Pull requests are welcome for these and any other potential improvements.

  • revise the script timeout to account for process completion
  • add doctests and fuller test coverage
  • provide error handling

aqfr's People

Contributors

barcek avatar

Watchers

 avatar

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.