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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Usage:
cf list [<specifier>...]
cf parse [<specifier>...]
cf gen [<alias>]
cf test [<file>]
cf test [-d] [<file>]
cf watch [all] [<specifier>...]
cf open [<specifier>...]
cf stand [<specifier>...]
Expand All @@ -48,6 +48,7 @@ Options:
--version Show version.
-f <file>, --file <file>, <file>
Path to file. E.g. "a.cpp", "./temp/a.cpp"
-d --debug Run with debugging before script.
<specifier> Any useful text. E.g.
"https://codeforces.com/contest/100",
"https://codeforces.com/contest/180/problem/A",
Expand Down Expand Up @@ -85,6 +86,7 @@ Examples:
test all samples. If you want to add a new testcase,
create two files "inK.txt" and "ansK.txt" where K is
a string with 0~9.
cf test -d Run with debugging before script
cf watch Watch the first 10 submissions of current contest.
cf watch all Watch all submissions of current contest.
cf open 1136a Use default web browser to open the page of contest
Expand Down
1 change: 1 addition & 0 deletions cmd/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ParsedArgs struct {
Alias string `docopt:"<alias>"`
Accepted bool `docopt:"ac"`
All bool `docopt:"all"`
Debug bool `docopt:"--debug"`
Handle string `docopt:"<handle>"`
Version string `docopt:"{version}"`
Config bool `docopt:"config"`
Expand Down
9 changes: 8 additions & 1 deletion cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,14 @@ func Test() (err error) {
return nil
}

if err = run(template.BeforeScript); err != nil {
beforeScript := template.BeforeScript
if Args.Debug {
if template.DbgBeforeScript==""{
return errors.New("debugging_before_script is not set in ~/.cf/config")
}
beforeScript = template.DbgBeforeScript
}
if err = run(beforeScript); err != nil {
return
}
if s := filter(template.Script); len(s) > 0 {
Expand Down
17 changes: 9 additions & 8 deletions 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 All @@ -13,13 +13,14 @@ import (

// CodeTemplate config parse code template
type CodeTemplate struct {
Alias string `json:"alias"`
Lang string `json:"lang"`
Path string `json:"path"`
Suffix []string `json:"suffix"`
BeforeScript string `json:"before_script"`
Script string `json:"script"`
AfterScript string `json:"after_script"`
Alias string `json:"alias"`
Lang string `json:"lang"`
Path string `json:"path"`
Suffix []string `json:"suffix"`
BeforeScript string `json:"before_script"`
DbgBeforeScript string `json:"debugging_before_script"`
Script string `json:"script"`
AfterScript string `json:"after_script"`
}

// Config load and save configuration
Expand Down
5 changes: 4 additions & 1 deletion config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,15 @@ func (c *Config) AddTemplate() (err error) {
color.Red("Script can not be empty. Please input again: ")
}

color.Cyan(`Debugging before script (e.g. "g++ $%full%$ -o $%file%$.exe -std=c++11 -Donline_judge"), empty is ok: `)
dbgBeforeScript := util.ScanlineTrim()

color.Cyan(`After script (e.g. "rm $%file%$.exe" or "cmd.exe /C del $%file%$.exe" in windows), empty is ok: `)
afterScript := util.ScanlineTrim()

c.Template = append(c.Template, CodeTemplate{
alias, lang, path, suffix,
beforeScript, script, afterScript,
beforeScript, dbgBeforeScript, script, afterScript,
})

if util.YesOrNo("Make it default (y/n)? ") {
Expand Down