GithubHelp home page GithubHelp logo

prasoonbatham11 / cfcli Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 1.0 1.29 MB

Command Line Interface for Codeforces

License: MIT License

Python 100.00%
python cli codeforces terminal programming colorama termgraph gnuplotlib linux coding

cfcli's Introduction

Cool cfcli Logo

Codeforces cli for lazy nerds who don't want to leave their cozy terminals.

License Python

Installation

pip install cfs

OR

git clone https://github.com/prasoonbatham11/cfcli.git
python3 setup.py install

Usage

Use -h or --help to see usage.

cfs -h

View User Details

# Shows basic details of the user specified
cfs -u prasoonbatham

View Rating Graph of User

# Shows Rating change graph of user
cfs -g prasoonbatham

Rating Graph of user is displayed as a gnuplot.

View Contest Details

Contest ID can be found in the url of contest such as: /contest/1137/.

# Shows details of contest specified by contest id
cfs -c 1137

# To view Contests from gym
cfs -c 102134 --gym

Interact With Problemset Subcommand Interface

These commands retrieve the specified problemset (by tag or whole) and open a python cmd sub-terminal where various other actions can be performed.

# Loads all the problems
cfs -p

# Specify a problemset tag
cfs -p --tag dp

The sub-interface has the following commands:

  • View available commands: ?
  • List n Problems (max 15): list n
  • Reset the pointer to list problems: reset
  • List problems of contest id 'cid': listc cid
  • List 10 problems specified by index: listi index
  • View problem details specified by name: listn name
  • View problem details specified by index: prob index
  • View problem statement specified by contestid+index: stat 1133A

Say the following is the output for 8 problems

cf> list 8
0: Circus
1: Sushi for Two
2: Matches Are Not a Child's Play 
3: Train Car Selection
4: Cooperative Game
5: Museums Tour
6: Camp Schedule
7: Skyscrapers
cf> list 8
8: Spanning Tree with One Fixed Degree
9: Spanning Tree with Maximum Degree
10: K Balanced Teams
11: Zero Quantity Maximization
12: Balanced Team
13: Preparation for International Women's Day
14: Middle of the Contest
15: Greedy Subsequences
cf> 

To reset the pointer back to 0 we use reset command.

Similar to list, listc is used to list problems of a particular contest.

cf> listc 1133
8: Spanning Tree with One Fixed Degree
9: Spanning Tree with Maximum Degree
10: K Balanced Teams
11: Zero Quantity Maximization
12: Balanced Team
13: Preparation for International Women's Day
14: Middle of the Contest

In codeforces every problem has an index ('A', 'B', etc.). To view the problems by index use listi. To reset the pointer, again use reset command.

cf> listi B
0: Circus
6: Camp Schedule
13: Preparation for International Women's Day
20: Discounts
27: Draw!
30: Two Cakes
35: Wrong Answer
39: Mike and Children
45: Once in a casino
53: Tanya and Candies

listn and prob are used to view problem details by name and serial number respectively

cf> listn Sushi for Two
        |Problem Details

        |Name            :    Sushi for Two
        |Contest ID      :    1138      
        |Index           :    A         
        |Points          :    500.0     
        |Rating          :    900       
        |Solved By       :    3940      
cf> prob 0
        |Problem Details

        |Name            :    Circus    
        |Contest ID      :    1138      
        |Index           :    B         
        |Points          :    1000.0    
        |Rating          :    1700      
        |Solved By       :    1147 

To view any problem statement use stat command. This opens a paged output where you can see problem statement.

cf> stat 1133A

View A Blog Entry Specified By Blog ID

Blog ID can be found in the url of blog such as: /blog/entry/14565/.

# View blog specified by blog id
cfs -b 14565

The blog is displayed in a paged output with a proper comment thread. The comment thread is hierarchical, i.e., a reply to a comment is separated by one tab space from its parent comment.

View Rating Change For Users In A Contest

# View blog specified by blog id
cfs -rc 1137

# Specify a particular handle
cfs -rc 1137 --handle Petr

Get Blog Entries Of A User

# Get all blog entries of Petr
cfs -bu Petr

The subcommand interface is implemented using cmd python package and has the following commands.

  • View available commands: ?
  • List n Blog Entries (max 15): list n
  • Reset the pointer to list blog entries from: reset
  • View particular blog entry specified by index: vidx 65854
  • View particular blog entry specified by serial no: viewi 13

Say we get the following output by running list 5 for user Petr:

cf> list 5
0: 65854   An oracle week
1: 65574   A WTF week
2: 65328   A snack week
3: 65152   A tourist week
4: 64991   A mumbling week

Running list 5 again will return the next 5 entries.Now an internal pointer idx points to entry 10. To reset it we run reset.

cf> list 5
5: 64854   A Galois week
6: 64669   An anti-library week
7: 64501   A Dilworth week
8: 64349   A Radewoosh week
9: 64346   And the best problem of 2018 is...
cf> reset
cf> list 5
0: 65854   An oracle week
1: 65574   A WTF week
2: 65328   A snack week
3: 65152   A tourist week
4: 64991   A mumbling week
cf> 

To view the entry A galois week we can either run:

cf> viewi 5 

OR

cf> vidx 64854  

Get Submissions For A Specified User

To display all the submissions of the user use:

cfs -us prasoonbatham

You can also specify fr and count arguments to see count number of submissions from a particular index fr.

# Display 10 submissions from 5th index
cfs -us prasoonbatham --fr 5 --count 10

The default values for fr and count are 1 and 10 respectively. If either one of these are specified the other one takes default value.

For instance, if we want to retrieve 10 submissions from 5th index we can write.

# Here count takes the default value 10
cfs -us prasoonbatham --fr 5

Similarly,

# Display 20 submissions from 1st index
cfs -us prasoonbatham --count 20

View Contest Submissions

# Display contest submissions specified by contest id
cfs -cs 1137

Here too you can specify fr and count arguments to see submissions. And it works similar to user submissions.

# Display 100 submissions from index 50
cfs -cs 1137 --fr 50 --count 100

Another optional parameter to specify here is: handle which retrieves submissions only by the user specified.

# Display 10 submissions for user Petr from index 3 in contest 556
cfs -cs 556 --fr 3 --count 10 --handle Petr

Compare Two Users

cfs --compare prasoonbatham Petr

Seriously who am I comparing myself to!

TODO

  • Add Command for submitting a solution.
  • Improve rendering of problem statement.
  • Add proxy support.
  • Add command to recommend problems

Contribute

cfcli's People

Contributors

prasoonbatham11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ashishnamdev

cfcli's Issues

having problem using command -g to see graph

cfs -g ashiknur
The system cannot find the path specified.

    Rating Chart for user :  ashiknur

Traceback (most recent call last):
File "C:\Users\FAMILY\AppData\Local\Programs\Python\Python37\Scripts\cfs-script.py", line 11, in
load_entry_point('cfs==1.0.4', 'console_scripts', 'cfs')()
File "c:\users\family\appdata\local\programs\python\python37\lib\site-packages\cf_main_.py", line 79, in main

user_rating(json.loads(res.text))

File "c:\users\family\appdata\local\programs\python\python37\lib\site-packages\cf\user_rating.py", line 23, in user_rating
plotterm(x,y)
File "c:\users\family\appdata\local\programs\python\python37\lib\site-packages\cf\util.py", line 68, in plotterm

gnuplot = subprocess.Popen(["/usr/bin/gnuplot"], stdin=subprocess.PIPE)

File "c:\users\family\appdata\local\programs\python\python37\lib\subprocess.py", line 800, in init
restore_signals, start_new_session)
File "c:\users\family\appdata\local\programs\python\python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

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.