0.0.2 • Published 6 years ago

tocs v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Install

npm install -g tocs

tocs is a command-tools, which type text-file to c-string. for example, if you have a file with content like:

// a.cpp
#include <cstdio>
using namespace std;

int main() {
    int T_T, A, B;
    scanf("%d", &T_T);
    for(int kase=1; kase <= T_T; ++kase) {
        scanf("%d%d", &A, &B);
        printf("%d\n", A+B);
    }
    return 0;
}

and if you want post this in a json-format with tool like postman, it will be really annoy for the quotes.

and now, you could use tocs a.cpp --copy without any pain to get its something like:

"#include <cstdio>\r\nusing namespace std;\r\n\r\nint main() {\r\n    int T_T, A, B;\r\n    scanf(\"%d\", &T_T);\r\n    for(int kase=1; kase <= T_T; ++kase) {\r\n        scanf(\"%d%d\", &A, &B);\r\n        printf(\"%d\\n\", A+B);\r\n    }\r\n    return 0;\r\n}\r\n"

Usage

tocs <filename> [options]

options

  • -c, --copy: copy the result to your system-clipboard. Default value is false.
  • -C, --charset <charset>: specified file's encoding. Default value is utf-8.