Giter Site home page Giter Site logo

fixcom's Introduction

fixcom

Script to fix comments into a file.

Usage

Just for the explanation:

  • optional arguments are inside ()
  • the value of an argument is inside <>

python3 main.py (-h) (-n) (-s) (-a) (-c <format_case>) (-e <excluded_words>) -t <comment_symbol> filename

Arguments explanation

Mandatory arguments

  • -t, --type: comment symbol (like // for C/C++, # for Python etc...) surrouned by '
    • Example: --type '#'
  • filename: the file that needs comment formatting. MUST BE THE LAST ARGUMENT

Optional arguments

Without value:

  • -h, --help: prints the info message
  • -n, --no-space: formats without space after the command symbol
    • Example: # this is a comment becomes #this is a comment
  • -s, --spaces: removes extra spaces after comment symbol
    • Example:
      #     this   is a  comment
      becomes # this is a comment
  • -a, --all: applies uppercase / lowercase to all words after comment symbol
    • Example: # THis Is A COMMent becomes # this is a comment or # THIS IS A COMMENT respecting excluded words

With value:

  • -c, --case: u, upper or l, lower. Formatting type. Default: u
    • Example: # this is a comment becomes # This is a comment (without --all)
  • -e, --exclude: string of words separated by , and surrounded by '
    • Example: --exclude 'NULL,ERROR'. # VALUE is NULL with -c lower -all becomes # value is NULL

Example

test.c:

#include <stdio.h>

// main     function
int main() {
    //p poINTS to NULL
    int *p = NULL;
    //RETURNS 0
    return 0;
}

Comment formatting: python3 main.py -s -a -t '//' -c lower -e 'NULL' test.c

Result (new_test.c):

#include <stdio.h>

// main function
int main() {
    // p points to NULL
    int *p = NULL;
    // returns 0
    return 0;
}

fixcom's People

Contributors

fabifont avatar

Stargazers

Sumesh Pradhan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.