Please read the new rule regarding the restriction on the use of AI tools. ×

ghoudiy's blog

By ghoudiy, history, 4 hours ago, In English

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

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

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.

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! :)

Tags cli
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by ghoudiy (previous revision, new revision, compare).