Flip output is an interactive command-line tool that helps you manage output statements in C/C++/Rust/Java/Go code. It works by recursively searching your codebase and lets you toggle statements with an intuitive interface.
- Interactive by default - Beautiful TUI for selecting specific statements with file navigation
- Fast and recursive - Processes entire directory trees including subdirectories
- Flexible filtering - Detects all output functions by default, or use
--debugto filter by keyword - Preview mode - Preview changes without modifying files with
--preview - Safe and reversible - Disable output for production (
on), enable for debugging (off) - Smart detection - Automatically detects printf-family functions, C++ streams, Rust macros, Java output statements, and Go fmt/log functions
- Syntax highlighting - Color-coded output similar to ripgrep for easy reading
- Multiple modes - Comment out, uncomment, or permanently delete statements
# Disable all output (interactive TUI by default)
$ flop on
# Disable only debug output (interactive)
$ flop on --debug
# Disable all output in batch mode (with confirmation)
$ flop on --yes
# Preview what would be changed without modifying files
$ flop on --preview src/
# Disable debug output only in batch mode
$ flop on -dy src/
# Delete all output statements permanently (interactive)
$ flop delete src/
# Process a single file
$ flop on main.cIf you're a Rust programmer, flop can be installed with cargo:
cargo install flop-cliYou'll need Rust installed (1.70.0 or newer).
git clone https://github.com/Justhiro55/flop.git
cd flop
cargo build --releaseThe binary will be available at ./target/release/flop.
cargo install --path .
# Or copy the binary manually
sudo cp target/release/flop /usr/local/bin/flop <COMMAND> [OPTIONS] [PATH]
Commands:
off Uncomment output statements (enable output)
on Comment out output statements (disable output)
delete Delete output statements permanently
Arguments:
[PATH] Path to file or directory (defaults to current directory if not specified)
Options:
-d, --debug Only process output statements containing 'debug' keyword
-y, --yes Skip interactive selection (batch mode, confirmation still required)
-p, --preview Preview mode - show what would be changed without modifying files
-h, --help Print help
By default, flop searches for all C/C++/Rust/Java/Go output functions in your codebase. Use the --debug flag to filter only statements containing "debug" or "DEBUG" keywords.
Detected output functions include:
- C standard I/O functions (printf family, puts family, write, perror)
- C++ stream operators (std::cout, std::cerr, std::clog)
- Rust macros (println!, eprintln!, dbg!, etc.)
- Java output statements (System.out, System.err)
- Go fmt/log functions (fmt.Println, fmt.Printf, log.Println, etc.)
Supported file extensions:
.c.h.cpp.hpp.cc.cxx.rs.java.go
Detected functions:
C standard functions:
printf(),fprintf(),sprintf(),snprintf(),dprintf()puts(),fputs()write()perror()printf_debug()
C++ streams:
std::coutstd::cerrstd::clog
Rust macros:
println!(),eprintln!()print!(),eprint!()dbg!()
Java statements:
System.out.println(),System.out.printf(),System.out.print()System.err.println(),System.err.printf(),System.err.print()
Go functions:
fmt.Println(),fmt.Printf(),fmt.Print()fmt.Fprintln(),fmt.Fprintf(),fmt.Fprint()log.Println(),log.Printf(),log.Print()log.Fatal*(),log.Panic*()
By default, flop opens an interactive TUI where you can select which statements to process:
# Disable all output statements (interactive)
flop on
# Navigate with arrow keys or hjkl
# Toggle selection with Space/Tab
# Navigate between files with Left/Right arrows
# Press Enter to confirm, Esc/q to cancel# Interactively disable all output
flop on
# Disable only debug output (interactive)
flop on --debug# Interactively enable all output
flop off src/
# Enable only debug output (interactive)
flop off --debug src/Use -y or --yes to skip interactive selection and process all matched statements (confirmation still required):
# Disable all output in batch mode
flop on --yes
# Disable debug output only in batch mode
flop on -dy src/
# Enable all output in batch mode
flop off -y# Interactive mode
flop on main.c
# Batch mode
flop on -y main.c# Interactive deletion
flop delete src/
# Batch deletion (confirmation required)
flop delete -y src/Warning: This permanently removes statement lines from your files. Use with caution!
Preview what would be changed without actually modifying any files:
# Preview changes (interactive)
flop on --preview src/
# Preview in batch mode
flop on -yp src/
# Preview debug output only
flop on -dp src/Preview mode never modifies files. It's useful for:
- Checking what statements will be affected before committing
- Verifying detection patterns
- Safely exploring the tool's behavior
By default, flop detects all output functions. Use --debug to filter only statements containing "debug" or "DEBUG" keywords:
# Process only debug output (interactive)
flop on --debug
# This will detect:
# - printf("debug: message") ← detected
# - printf("Regular message") ← NOT detected with --debug
# - std::cout << "DEBUG: xyz" ← detectedWhen prompted for confirmation, type n to cancel without making changes:
Do you want to disable (comment out) these statements? (y/n): n
Operation cancelled.
cargo build --releaseThe repository includes sample C files in the tests/ and sample/ directories for testing:
# Build the project
cargo build --release
# Navigate to the tests directory and run flop without path argument
cd tests/
../target/release/flop on
# Disable all debug statements (type 'y' to confirm)
../target/release/flop on
# Verify they are commented out
cat main.c
# Enable all debug statements (type 'y' to confirm)
../target/release/flop off
# Verify they are uncommented
cat main.c
# Go back to project root
cd ..You can also test with the sample/ directory which contains more comprehensive examples:
./target/release/flop on sample/- Speed up your workflow - No need to manually toggle output statements
- Interactive by default - Beautiful TUI with file navigation makes selection intuitive
- Avoid mistakes - Preview mode and confirmation prompts prevent accidental changes
- Clean commits - Easily disable output before committing (
flop on) - Quick debugging - Enable output when investigating issues (
flop off) - Production cleanup - Permanently delete statements with the delete command
- Safe exploration - Use
--previewto preview changes before applying them - Flexible filtering - Process all output or filter by debug keyword with
--debug - Batch automation - Use
--yesflag for scripts while keeping confirmation
- Language specific - Only works with C/C++/Rust/Java/Go code
- Simple pattern matching - May not catch all debug logging patterns
- Standard output only - Doesn't work with some logging libraries (log4c, spdlog, SLF4J, etc.)
This project is dual-licensed under the MIT License and Apache License 2.0.
See LICENSE for details.
