cf-tool icon indicating copy to clipboard operation
cf-tool copied to clipboard

cf submit does not detect the contest ID

Open ericbrandwein opened this issue 4 years ago • 1 comments

When I'm in a directory <contest-number>/<problem-id>, typing cf submit gives the output

Submit CONTEST
You have to specify the Contest ID

Adding the contest number and problem ID to the command seems to work.

The expected behavior, as stated in the README, is to use the contest number and the problem ID from the file path instead of having to type it by hand.

ericbrandwein avatar Jul 10 '20 16:07 ericbrandwein

Okey, found the problems, all of them in the regex being used in the parsePath function of args.go:

  1. If in the config file there's a / at the end of a folder name, the resulting regex will have one extra / in between folder names, because the regex adds one more. To fix this, the format of the folder names in the config file should be made clear in the README or somewhere else, or the extra / should be removed from the directory names before adding them to the regex.
  2. If in the config file the "contest" folder_name is empty, then the regex treats it as if there were an empty folder, instead of there being no folder. For example, if the "root" folder_name is "/home/eric", and the "contest" folder_name is "", the resulting regex will be /home/eric//<contest_id>/<problem_id>. Maybe it should check if a folder name is empty and not add it to the regex if that's the case. At least, there should be some documentation about the config file so that this doesn't happen again.
  3. The regex uses the root folder name, meaning that if the folder where all the contests are parsed is symlinked from another location and I change directory from that location, the regex doesn't work anymore. Even if not symlinking, any folder inside the home folder is accesible in two ways: ~/folder and /home/eric/folder, so using the root folder in the regex is not suitable. Instead of using the root folder name, it should just check the deepest two or three directory names to see which type of problem this is. For example, if I'm inside /home/eric/CP/contest/1371/a, and the contest folder_name is "contest", it should just check if the end of the path matches the regex /contest/<contest_number>/<problem_id>.

ericbrandwein avatar Jul 10 '20 18:07 ericbrandwein