Package: cmd-interceptor
cmd-interceptorA tool to intercept calls to your command line tools and alter their args.Requires UNIX and working Python3 and whereis.InstallationSince theinterceptorPyPI package name is taken,
you ought to install interceptor the following way:pipinstallcmd-interceptorOr, if you don't have pip:gitclonehttps://github.com/Dronehub/interceptor.gitcdinterceptor
pythonsetup.pyinstallUsagePrepare the configurationTo override g++ put a JSON file at/etc/interceptor.d/g++with the following contents:{"args_to_disable":["-quiet"],"args_to_append":["-DDEBUG"]],"args_to_prepend":["-v"],"args_to_replace":[["-march=native","-mcpu=native"]],"display_before_start":true,"notify_about_actions":false}ConfiguringIf the intercepted command sees any arguments given inargs_to_disablethey will be removed before being passed to target command.You give two-item lists inargs_to_replace. If
the first item occurs in arguments, it will be replaced by the second item.If arguments inargs_to_appendare not in arguments,
they will be appended to the arguments.The arguments inargs_to_appendwill be appended in the order they are listed.If arguments inargs_to_prependare not in arguments,
they will be prepended to arguments.The arguments inargs_to_prependwill be appended in the order they are listed.If you don't prepare the configuration file in advance, an empty file will be created for you.Ifdisplay_before_startis set, then before the launch
the application name and parameters actually passed to it will be displayed on stdout.Ifnotify_about_actionsis set, then interceptor will print out
each case an action is attempted.The intercept commandTheinterceptcommand is the basic command used to interface with interceptor.Intercepting toolsSay, to intercept the commandfooinvoke:interceptfooNote that foo's executable must be discoverable by whereis. There should be
ideally a single executable file, otherwise interceptor will patch all of them.
Interceptor should display the following:Successfully intercepted fooNote that you will be unable to proceed if foo is already an interceptor wrapper.A Python wrapper will be found at previous location of
foo, while it itself will be copied to the same directory
but namedfoo-intercepted.
The wrapper will hold the name offooinside,
so you can symlink it safely (eg. symlink of g++ to c++).To cancel interceptingfootype:interceptundofooTo check whetherfoois being intercepted type:interceptstatusfooThis will additionally validate and reformat it's configuration file.
This will return information about whether it's config is a symlink, or whether the tool
is partially patched (ie. there are executables reachable within PATH that haven't been patched).
To rectify this issue just typeinterceptfoo--forceAny call of intercept with a single argument (and optional switch) will be treated as order to
intercept this command, so if you're trying to intercept, sayshowyou just type:interceptshowTo provide configuration forfootypeinterceptconfigurefoo```And type in the configuration in JSON format, followed by Ctrl+D.To display current configuration forfootype:interceptshowfooTo have intercept display when the tool is called type:interceptdisplayfooTo hide the display type:intercepthidefooTo have nano/vi run to edit your config file type:intercepteditfooTo add an argument to be appended to the command type:interceptappendfooargTo add an argument to be prepended to the command type:interceptprependfooargTo add an argument to be eliminated if foo is called with it
type:interceptdisablefooargTo replace arg1 with arg2 each time foo is called type:interceptreplacefooarg1arg2To have intercept display when an action is taken type:interceptnotifyfooTo hide the notifications type:interceptunnotifyfooTo symlink bar's configuration to that of foo type:interceptlinkfoobarTo copy foo's configuration to that of bar type:interceptcopyfoobarNote that intercept will refuse to link to foo if foo is already a symlink.
To circumvent that type:interceptlinkfoobar--forceTo toggle argument deduplication (only unique arguments will be passed) type:interceptenable-deduplicationfoo# enable itinterceptdisable-deduplicationfoo# disable itTo append all calls to this instruction into/var/log/inteceptor.d/instruction_name:interceptlogfoo# enable itinterceptunlogfoo# disable itTo reset configuration of foo, typeinterceptresetfooThis will tell you if foo's configuration was a symlink.
Note that this will unlink foo is it is already a symlink.Note that many of the aforementioned commands check first to see it foo is intercepted.
You can pass --force to skip that check.If you mean to pass --force as an argument, and not as a switch, interceptor will treat only
the first --force found as a switch and remove it from further command processing.
Rethink your naming of commands in that case.