Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ cf
*.out

.vscode
bin
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!make

all: build

.PHONY: vet
vet:
go vet ./...

.PHONY: fmt
fmt:
go fmt ./...

.PHONY: clean
clean:
rm -rf ./bin/*

.PHONY: build
build: clean fmt
mkdir -p ./bin/
go build -o ./bin/cf ./cf.go

.PHONY: run
run: clean fmt vet
go run ./...

.PHONY: test
test: vet
go test -v -failfast ./...
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"path/filepath"

"github.com/fatih/color"
"github.com/xalanq/cf-tool/cookiejar"
// "github.com/xalanq/cf-tool/cookiejar"
"net/http/cookiejar"
)

// Client codeforces client
Expand Down
3 changes: 2 additions & 1 deletion client/langs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package client

// Langs generated by
// ^[\s\S]*?value="(.+?)"[\s\S]*?>([\s\S]+?)<[\s\S]*?$
// "\1": "\2",
//
// "\1": "\2",
var Langs = map[string]string{
"43": "GNU GCC C11 5.1.0",
"52": "Clang++17 Diagnostics",
Expand Down
4 changes: 3 additions & 1 deletion client/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"syscall"

"github.com/fatih/color"
"github.com/xalanq/cf-tool/cookiejar"
// "github.com/xalanq/cf-tool/cookiejar"
"net/http/cookiejar"

"github.com/xalanq/cf-tool/util"
"golang.org/x/crypto/ssh/terminal"
)
Expand Down
16 changes: 9 additions & 7 deletions client/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"strings"
"sync"

"github.com/xalanq/cf-tool/util"

"github.com/k0kubun/go-ansi"

"github.com/draychev/go-toolbox/pkg/logger"
"github.com/fatih/color"
"github.com/k0kubun/go-ansi"
"github.com/xalanq/cf-tool/util"
)

var log = logger.NewPretty("client")

func findSample(body []byte) (input [][]byte, output [][]byte, err error) {
irg := regexp.MustCompile(`class="input"[\s\S]*?<pre>([\s\S]*?)</pre>`)
org := regexp.MustCompile(`class="output"[\s\S]*?<pre>([\s\S]*?)</pre>`)
Expand Down Expand Up @@ -123,13 +124,14 @@ func (c *Client) Parse(info Info) (problems []string, paths []string, err error)
go func(problemID, path string) {
defer wg.Done()
mu.Lock()
fmt.Printf("Parsing %v\n", problemID)
fmt.Printf("Parsing contest:%s, problem:%v into %s\n", info.ContestID, problemID, path)
mu.Unlock()

err = os.MkdirAll(path, os.ModePerm)
if err != nil {
if err = os.MkdirAll(path, os.ModePerm); err != nil {
log.Error().Err(err).Msgf("Error creating directory %s", path)
return
}
log.Debug().Msgf("Created directory: %s", path)
URL := fmt.Sprintf(urlFormatter, problemID)

samples, standardIO, err := c.ParseProblem(URL, path, &mu)
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package config

import (
"bytes"
"encoding/json"
"io/ioutil"
"os"
"bytes"
"path/filepath"

"github.com/fatih/color"
Expand Down
Loading