Skip to content

Commit

Permalink
chore(valeria): -v verbose flag + Makefile deps fix (#16)
Browse files Browse the repository at this point in the history
* chore(valeria): -v verbose flag + Makefile deps fix

* chore: readme update
  • Loading branch information
Gornak40 authored Feb 19, 2024
1 parent e8d6651 commit ef7e210
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
BIN_DIR := bin
TOOLS := $(notdir $(wildcard cmd/*))
TOOL_TARGETS := $(addprefix $(BIN_DIR)/, $(TOOLS))
GO_FILES := $(shell find $(SRC_DIRS) -type f -name '*.go')

all: $(TOOL_TARGETS)

$(TOOL_TARGETS): $(GO_FILES)

$(BIN_DIR)/%: cmd/%/main.go
@mkdir -p $(BIN_DIR)
go build -o $@ $<
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Build
```bash
sudo apt install go
make build
make
export PATH=$(pwd)/bin:$PATH
```

Expand Down Expand Up @@ -166,6 +166,7 @@ Thanks to Mike, it's been working fast since 30.01.2024.

### Flags
- `-i` - problem id (required)
- `-v` - print valuer.cfg in stderr

### Config
- `polygon.url`
Expand All @@ -175,7 +176,7 @@ Thanks to Mike, it's been working fast since 30.01.2024.
### Examples
```bash
valeria --help
valeria -i 288808
valeria -i 288808 -v
valeria -i 318511 > scoring.tex
valeria -i 318882 | bat -l tex
```
Expand Down
6 changes: 5 additions & 1 deletion cmd/valeria/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ func main() {
Required: true,
Help: "Polygon problem ID",
})
verbose := parser.Flag("v", "verbose", &argparse.Options{
Required: false,
Help: "Print valuer.cfg in stderr",
})
if err := parser.Parse(os.Args); err != nil {
logrus.WithError(err).Fatal("bad arguments")
}

cfg := config.NewConfig()
pClient := polygon.NewPolygon(&cfg.Polygon)

if err := pClient.InformaticsValuer(*pID); err != nil {
if err := pClient.InformaticsValuer(*pID, *verbose); err != nil {
logrus.WithError(err).Fatal("failed get scoring")
}
}
6 changes: 4 additions & 2 deletions polygon/scoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (s *Scoring) buildScoring() string {
return strings.Join(ans, "\n")
}

func (p *Polygon) InformaticsValuer(pID int) error {
func (p *Polygon) InformaticsValuer(pID int, verbose bool) error {
groups, err := p.GetGroups(pID)
if err != nil {
return err
Expand All @@ -113,7 +113,9 @@ func (p *Polygon) InformaticsValuer(pID int) error {
return err
}
valuer := s.buildValuer()
logrus.Info("valuer:\n" + valuer)
if verbose {
logrus.Info("valuer.cfg\n" + valuer)
}

link := p.buildURL("problem.saveFile", url.Values{
"problemId": []string{strconv.Itoa(pID)},
Expand Down

0 comments on commit ef7e210

Please sign in to comment.