Skip to content

Universal command Line Wrapper, commonly used for modifying command line arguments, recording command logs, and so on.

License

Notifications You must be signed in to change notification settings

sanfengAndroid/cli-wrapper

Repository files navigation

cli-wrapper

English | 简体中文

cli-wrapper as its name implies, is a cross-platform command line wrapper written in Rust. It provides various functionalities such as modifying command line arguments, redirecting output, printing logs, etc. It is mainly used in the software compilation process.

Build

cargo build --release

Features

The parameters starting with -clw- are used as internal configuration parameters. Currently, the following parameters are supported. Please note that the current version is not an official release version, so there may be significant code changes. For more details, you can refer to the implementation in main.rs. cli-wrapper supports the ResponseFile parameters supported by the gcc/clang compilers. If cli-wrapper cannot parse the -clw- configuration, it will be preserved in the command line.

Keyword Description
-clw-just-print Only print the final executed command without actually executing it
-clw-before-print Print the final executed command and its arguments before actually executing it
-clw-log-file=<log file> Redirect cli-wrapper internal log to file in append mode
-clw-command=<command> Replace the current program execution with command, other parameters remain unchanged
-clw-work-dir=<working directory> Change the working directory for command execution
-clw-redirect-stdout=<file path> Redirect stdout to the specified file, can be the same path as stderr
-clw-redirect-stderr=<file path> Redirect stderr to the specified file, can be the same path as stdout
-clw-remove=<arg> Remove all <arg> command line arguments
-clw-replace-<before>=<after> Replace all <before> command line arguments with <after>
-clw-static-link-compiler=<arg> Replace the <arg> library in the linking command with static linking. It will remove all previous <arg> arguments and append -Wl,-Bstatic, -Wl,<arg>. Applicable to compilers such as gcc/clang.
-clw-dynamic-link-compiler=<arg> Replace the <arg> library in the linking command with dynamic linking. It will remove all previous <arg> arguments and append -Wl,-Bdynamic, -Wl,<arg>. Applicable to compilers such as gcc/clang.
-clw-static-link=<arg> Replace the <arg> library in the linking command with static linking. It will remove all previous <arg> arguments and append -Bstatic, <arg>. Applicable to linkers such as ld/lld.
-clw-dynamic-link=<arg> Replace the <arg> library in the linking command with dynamic linking. It will remove all previous <arg> arguments and append -Bdynamic, <arg>. Applicable to linkers such as ld/lld.

Examples

  1. Replace all dynamic link libc.so with static link libc.a in the linking command

    # For gcc/clang compiler driving linker, where <arg> is -lc
    cli-wrapper gcc <original arguments> -clw-static-link-compiler=-lc
    
    # For ld/lld linker replacement
    cli-wrapper ld <original arguments> -clw-static-link=-lc
  2. Remove all arguments -lm

    cli-wrapper ld <original arguments> -clw-remove=-lm
  3. Replace all arguments -lm with -lm2

    cli-wrapper ld <original arguments> -clw-replace--lm=-lm2
  4. Print the final executed command before execution

    cli-wrapper ld <original arguments> -clw-before-print
  5. Redirect stdout to a file

    cli-wrapper ld <original arguments> -clw-redirect-stdout=output.txt

About

Universal command Line Wrapper, commonly used for modifying command line arguments, recording command logs, and so on.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages