flop
Flip output is an interactive command-line tool that helps you manage output statements in C/C++/Rust/Java code. It works by recursively searching your codebase and lets you toggle statements with an intuitive interface.

Features
- 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, and Java output statements
- Syntax highlighting - Color-coded output similar to ripgrep for easy reading
- Multiple modes - Comment out, uncomment, or permanently delete statements
Quick example
# Disable all output (interactive TUI by default)
# Disable only debug output (interactive)
# Disable all output in batch mode (with confirmation)
# Preview what would be changed without modifying files
# Disable debug output only in batch mode
# Delete all output statements permanently (interactive)
# Process a single file
Installation
From crates.io
If you're a Rust programmer, flop can be installed with cargo:
From source
You'll need Rust installed (1.70.0 or newer).
The binary will be available at ./target/release/flop.
Install to system
# Or copy the binary manually
Usage
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
How it works
By default, flop searches for all C/C++/Rust/Java 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)
Supported file extensions:
.c.h.cpp.hpp.cc.cxx.rs.java
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()
Examples
Interactive mode (default)
By default, flop opens an interactive TUI where you can select which statements to process:
# Disable all output statements (interactive)
# 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
Disable output in current directory
# Interactively disable all output
# Disable only debug output (interactive)
Enable output in a specific directory
# Interactively enable all output
# Enable only debug output (interactive)
Batch mode with --yes flag
Use -y or --yes to skip interactive selection and process all matched statements (confirmation still required):
# Disable all output in batch mode
# Disable debug output only in batch mode
# Enable all output in batch mode
Process a single file
# Interactive mode
# Batch mode
Delete statements permanently
# Interactive deletion
# Batch deletion (confirmation required)
Warning: This permanently removes statement lines from your files. Use with caution!
Preview mode with --preview flag
Preview what would be changed without actually modifying any files:
# Preview changes (interactive)
# Preview in batch mode
# Preview debug output only
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
Filter debug output with --debug flag
By default, flop detects all output functions. Use --debug to filter only statements containing "debug" or "DEBUG" keywords:
# Process only debug output (interactive)
# This will detect:
# - printf("debug: message") ← detected
# - printf("Regular message") ← NOT detected with --debug
# - std::cout << "DEBUG: xyz" ← detected
Cancel operation
When prompted for confirmation, type n to cancel without making changes:
Do you want to disable (comment out) these statements? (y/n): n
Operation cancelled.
Building
Testing
The repository includes sample C files in the tests/ and sample/ directories for testing:
# Build the project
# Navigate to the tests directory and run flop without path argument
# Disable all debug statements (type 'y' to confirm)
# Verify they are commented out
# Enable all debug statements (type 'y' to confirm)
# Verify they are uncommented
# Go back to project root
You can also test with the sample/ directory which contains more comprehensive examples:
Why use flop?
- 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
Why not use flop?
- Language specific - Only works with C/C++/Rust/Java code
- Simple pattern matching - May not catch all debug logging patterns
- Standard output only - Doesn't work with logging libraries (log4c, spdlog, log crate, Log4j, SLF4J, etc.)
License
This project is dual-licensed under the MIT License and Apache License 2.0.
See LICENSE for details.