ghoudiy's blog

By ghoudiy, 3 months ago, In English

cfkit is a lightweight and efficient CLI tool. It’s easy to use, fast and works across platforms.

It's written in Python. You can explore the source code on my GitHub repository: https://github.com/ghoudiy/cfkit/

Features:

  • Efficient Result Comparison: Compare floating-point numbers, allow any-order comparison, or use strict comparison.

  • High Traffic Resilience: Parses problem data even under server load.

  • Language Support: Compatible with all programming languages used on Codeforces.

  • Fetch Problem Samples: Retrieves sample test cases for problems.

  • Local Compilation and Testing: Compile and test solutions locally.

  • Template-Based Code Generation: Generate code with templates, including timestamps and author info.

  • Contest Problem Stats: Lists problem statistics for specific contests.

  • Enhanced CLI Output: Distinguish correct and incorrect results easily with colored output.

Installation

Ensure Python is installed on your system. Then, run these commands in your terminal:

  • pip install cfkit

  • cf config all

And your are ready to go!

Usage

cf run 2000a.cpp    Compiles and tests your solution locally,
                    fetching and parsing missing sample test cases,
                    then comparing your output to the expected results with highlighted differences.

Options:

-o: Accept answers in any order.
-c: Run only custom samples or use custom input without comparing results.
-s: Does not ignore extra spaces during comparison.
-n: Does not ignore extra new lines during comparison.
-v: Does not print input, output and answer.
-a: Does not print answers.

cf gen 2000a    Generates a code file from the default template.

How to Set Up a Default Template?

If you'd like to create a default template for C++ (for example), follow these steps:

  • Navigate to the template directory: $HOME/.cfkit/templates/cpp/
  • Create a file named default.cpp in this folder.
  • Inside default.cpp, write your desired C++ template code. This will be used automatically whenever you generate a new C++ file with cfkit.

In your template code, you can include various placeholders. (Read documentation here)

cf parse 2000   Fetch all sample test cases from a contest.

FAQ

Q: How do I add a new test case?
A: To add a new test case, create two files: inK.txt and outK.txt, where K is a number. If you're using Linux or MacOs, omit the .txt extension (e.g., in1, ou1, in2, out2). You can create additional test cases by increasing the value of K (e.g., in1.txt, out1.txt, in2.txt, out2.txt).

Q: How to update cfkit package?
A: pip install --upgrade cfkit

Q: How to change the current compiling or executing command in cfkit?

R: Go to .cfkit/languages.json in your home folder, find your language, and edit the command as needed.

Notes

  • Memory and time usage may not be precise.
  • If you're calculating memory and time usage, it's recommended to avoid spaces in file paths.
  • If you encounter errors during compilation or execution, navigate to $HOME/.cfkit/languages.json and modify the command as needed.
  • To customize the program’s behavior, run cf config edit. This will open the configuration file in your default text editor for easy adjustments.
  • To add new templates, navigate to $HOME/.cfkit/templates/LANGUAGE_FOLDER/ and create your template file there. When you run cf gen, cfkit will prompt you to choose a template if no default is set.
  • If you encounter an error during compilation or execution, you can modify the command in $HOME/.cfkit/languages.

Finally

I’m always open to feedback, suggestions, and collaboration! If you have any questions or want to get in touch, feel free to reach out:

Email: ghoudi.dev@gmail.com
Support: If you’d like to support my work and help me continue creating cool programs, you can do so here.
Looking forward to hearing from you! :)

Full text and comments »

Tags cli
  • Vote: I like it
  • +49
  • Vote: I do not like it