Skip to main content

CLI tool for managing and easily swapping between different versions of code by converting the code into comments and vice versa.

Project description

cleanbug

CLI tool for managing and easily converting the code into comments and vice versa. Define multiple modes and execute the command to swap between them. Comments all flags that are not the current mode and uncomment the flag that is the current mode.

Prerequisites

  • Python 3.6 or higher

Installation

pip install cleanbug

Usage

cleanbug <file_name> [<output_file_name>] --mode <flag> --config <config_file>

Config File

Can contain the parameters FLAGS, INLINE_COMMENT, MULTILINE_COMMENT. The starting and ending symbols of MULTILINE_COMMENT should be separated by spaces. Eg:

FLAGS = DEBUG DEV PROD
INLINE_COMMENT = //
MULTI_COMMENT = /* */
FLAGS = DEBUG DEV PROD BUILD
INLINE_COMMENT = #

MULTILINE_COMMENT can also be broken into MULTILINE_COMMENT_START and MULTILINE_COMMENT_END.

Input File

The flags should be written in the following format:

.<flag_name_1>[.<flag_name_2>...<flag_name_n>]

with each flag separated by a dot. The flags must be written in a single line, preceded and succeeded only by the comment symbol and whitespace.

Multiple Lines

To mark multiple lines under a single flag line, use a > sybmol as the first flag in the line. The end of the lines marked under those flags is marked by another flag line using the < symbol. The flag lines between the > and < symbols are marked under the same flag.

Example

Original Code:

void main() {
    // .DEV
    printf("Hello World!\n");
    // >.PROD
    printf("Hello There, World!\n");
    printf("Nice to meet you! \n");
    // <.PROD
    // .PROD.DEV
    printf("I'm Good!\n");
    printf("Nice to meet you! \n");
}

FLAG: DEV

cleanbug test/test.c --config test/cleanbug.config --mode DEV

void main() {
    // .DEV
    printf("Hello World!\n");
    // >.PROD
    /* printf("Hello There, World!\n");
    printf("Nice to meet you! \n"); */
    // <.PROD
    // .PROD.DEV
    printf("I'm Good!\n");
    printf("Nice to meet you! \n");
}

FLAG: PROD

cleanbug test/test.c --config test/cleanbug.config --mode PROD

void main() {
    // .DEV
    // printf("Hello World!\n");
    // >.PROD
    printf("Hello There, World!\n");
    printf("Nice to meet you! \n");
    // <.PROD
    // .PROD.DEV
    printf("I'm Good!\n");
    printf("Nice to meet you! \n");
}

FLAG: DEBUG

cleanbug test/test.c --config test/cleanbug.config --mode DEBUG

void main() {
    // .DEV
    // printf("Hello World!\n");
    // >.PROD
    /* printf("Hello There, World!\n");
    printf("Nice to meet you! \n"); */
    // <.PROD
    // .PROD.DEV
    // printf("I'm Good!\n");
    printf("Nice to meet you! \n");
}

Prevent Conversion from Comments to Code

The conversion from comment to code can be prevented by inserting a !! symbol after the comment symbol (separated only by whitespaces). Eg:

# !! NOTE: This is a note.

This allows for comment lines within the code to be ignored by the tool.

Output File

If the output file is not specified, the input file is overwritten with the converted code. If the output file is specified, the converted code is written to the output file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cleanbug-0.0.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cleanbug-0.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file cleanbug-0.0.1.tar.gz.

File metadata

  • Download URL: cleanbug-0.0.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for cleanbug-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fd985b9961bb339c1a3c4ebb315509d502c3cc1e292cc4cc20672356158ace8a
MD5 8195b57a7fafea3be7e95fd8fe05e69d
BLAKE2b-256 7f59154334de5dd63c5ef802b4576956dbe1223675acd3f2987885997650e63a

See more details on using hashes here.

File details

Details for the file cleanbug-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cleanbug-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for cleanbug-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a704b94d49f688145f9896045abf1e5aad330ebecce7f5730e37a016130073d1
MD5 12681a89e86d787e426893375182763d
BLAKE2b-256 c20fb2b2f5cac449be71ce2ac465c29867d74b2908853cc11afa837be9a57ecc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page