init
This commit is contained in:
commit
8041bf7bc0
1
.envrc
Normal file
1
.envrc
Normal file
@ -0,0 +1 @@
|
||||
export MONGODB_URI=mongodb+srv://root:root@localhost:27017?retryWrites=true&w=majority
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
./archivar
|
||||
inventory/
|
||||
dist/
|
||||
91
.goreleaser.yml
Normal file
91
.goreleaser.yml
Normal file
@ -0,0 +1,91 @@
|
||||
# This is an example .goreleaser.yml file with some sane defaults.
|
||||
# Make sure to check the documentation at http://goreleaser.com
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
# you may remove this if you don't need go generate
|
||||
- go generate ./...
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- openbsd
|
||||
archives:
|
||||
- replacements:
|
||||
darwin: Darwin
|
||||
linux: Linux
|
||||
openbsd: OpenBSD
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
name_template: "{{ .Tag }}-next"
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
brews:
|
||||
-
|
||||
# Name template of the recipe
|
||||
# Default to project name
|
||||
name: archivar
|
||||
|
||||
# GOARM to specify which 32-bit arm version to use if there are multiple versions
|
||||
# from the build section. Brew formulas support atm only one 32-bit version.
|
||||
# Default is 6 for all artifacts or each id if there a multiple versions.
|
||||
goarm: 6
|
||||
|
||||
# NOTE: make sure the url_template, the token and given repo (github or gitlab) owner and name are from the
|
||||
# same kind. We will probably unify this in the next major version like it is done with scoop.
|
||||
|
||||
# GitHub/GitLab repository to push the formula to
|
||||
# Gitea is not supported yet, but the support coming
|
||||
tap:
|
||||
owner: noqqe
|
||||
name: homebrew-tap
|
||||
# Optionally a token can be provided, if it differs from the token provided to GoReleaser
|
||||
|
||||
# Allows you to set a custom download strategy. Note that you'll need
|
||||
# to implement the strategy and add it to your tap repository.
|
||||
# Example: https://docs.brew.sh/Formula-Cookbook#specifying-the-download-strategy-explicitly
|
||||
# Default is empty.
|
||||
download_strategy: CurlDownloadStrategy
|
||||
|
||||
# Git author used to commit to the repository.
|
||||
# Defaults are shown.
|
||||
commit_author:
|
||||
name: goreleaserbot
|
||||
email: goreleaser@carlosbecker.com
|
||||
|
||||
# Folder inside the repository to put the formula.
|
||||
# Default is the root folder.
|
||||
folder: Formula
|
||||
|
||||
# Your app's homepage.
|
||||
# Default is empty.
|
||||
homepage: "https://github.com/noqqe/archivar"
|
||||
|
||||
# Your app's description.
|
||||
# Default is empty.
|
||||
description: "archivar - I wrote a typing trainer to get into my ortholinear keyboard"
|
||||
|
||||
# SPDX identifier of your app's license.
|
||||
# Default is empty.
|
||||
license: "MIT"
|
||||
|
||||
# So you can `brew test` your formula.
|
||||
# Default is empty.
|
||||
test: |
|
||||
system "#{bin}/archivar --version"
|
||||
|
||||
# Custom install script for brew.
|
||||
# Default is 'bin.install "program"'.
|
||||
install: |
|
||||
bin.install "archivar"
|
||||
|
||||
20
archivar.go
Normal file
20
archivar.go
Normal file
@ -0,0 +1,20 @@
|
||||
// Package main provides a typing test
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/noqqe/archivar/src/archivar"
|
||||
)
|
||||
|
||||
// Main Loop
|
||||
func main() {
|
||||
|
||||
var set_file string
|
||||
|
||||
// flags declaration using flag package
|
||||
flag.StringVar(&set_file, "f", "inventory/set-1.yml", "Specify set file")
|
||||
flag.Parse()
|
||||
|
||||
archivar.Start(set_file)
|
||||
}
|
||||
15
docker-compose.yaml
Normal file
15
docker-compose.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '3.7'
|
||||
services:
|
||||
mongodb:
|
||||
image: mongo:latest
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: root
|
||||
ports:
|
||||
- 27017:27017
|
||||
volumes:
|
||||
- mongodb_data:/data/db
|
||||
|
||||
volumes:
|
||||
mongodb_data:
|
||||
|
||||
8
go.mod
Normal file
8
go.mod
Normal file
@ -0,0 +1,8 @@
|
||||
module github.com/noqqe/archivar
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
go.mongodb.org/mongo-driver v1.8.1
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
)
|
||||
61
go.sum
Normal file
61
go.sum
Normal file
@ -0,0 +1,61 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w=
|
||||
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
|
||||
github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc=
|
||||
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
go.mongodb.org/mongo-driver v1.8.1 h1:OZE4Wni/SJlrcmSIBRYNzunX5TKxjrTS4jKSnA99oKU=
|
||||
go.mongodb.org/mongo-driver v1.8.1/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f h1:aZp0e2vLN4MToVqnjNEYEtrEA8RH8U8FN1CU7JgqsPU=
|
||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
133
src/archivar/card.go
Normal file
133
src/archivar/card.go
Normal file
@ -0,0 +1,133 @@
|
||||
package archivar
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Card struct {
|
||||
Artist string `json:"artist"`
|
||||
ArtistIds []string `json:"artist_ids"`
|
||||
Booster bool `json:"booster"`
|
||||
BorderColor string `json:"border_color"`
|
||||
CardBackID string `json:"card_back_id"`
|
||||
Cmc int64 `json:"cmc"`
|
||||
CollectorNumber string `json:"collector_number"`
|
||||
ColorIdentity []string `json:"color_identity"`
|
||||
Colors []string `json:"colors"`
|
||||
Digital bool `json:"digital"`
|
||||
EdhrecRank int64 `json:"edhrec_rank"`
|
||||
Finishes []string `json:"finishes"`
|
||||
Foil bool `json:"foil"`
|
||||
Frame string `json:"frame"`
|
||||
FullArt bool `json:"full_art"`
|
||||
Games []string `json:"games"`
|
||||
HighresImage bool `json:"highres_image"`
|
||||
ID string `json:"id"`
|
||||
IllustrationID string `json:"illustration_id"`
|
||||
ImageStatus string `json:"image_status"`
|
||||
ImageUris struct {
|
||||
ArtCrop string `json:"art_crop"`
|
||||
BorderCrop string `json:"border_crop"`
|
||||
Large string `json:"large"`
|
||||
Normal string `json:"normal"`
|
||||
Png string `json:"png"`
|
||||
Small string `json:"small"`
|
||||
} `json:"image_uris"`
|
||||
Keywords []interface{} `json:"keywords"`
|
||||
Lang string `json:"lang"`
|
||||
Layout string `json:"layout"`
|
||||
Legalities struct {
|
||||
Alchemy string `json:"alchemy"`
|
||||
Brawl string `json:"brawl"`
|
||||
Commander string `json:"commander"`
|
||||
Duel string `json:"duel"`
|
||||
Future string `json:"future"`
|
||||
Gladiator string `json:"gladiator"`
|
||||
Historic string `json:"historic"`
|
||||
Historicbrawl string `json:"historicbrawl"`
|
||||
Legacy string `json:"legacy"`
|
||||
Modern string `json:"modern"`
|
||||
Oldschool string `json:"oldschool"`
|
||||
Pauper string `json:"pauper"`
|
||||
Paupercommander string `json:"paupercommander"`
|
||||
Penny string `json:"penny"`
|
||||
Pioneer string `json:"pioneer"`
|
||||
Premodern string `json:"premodern"`
|
||||
Standard string `json:"standard"`
|
||||
Vintage string `json:"vintage"`
|
||||
} `json:"legalities"`
|
||||
ManaCost string `json:"mana_cost"`
|
||||
MultiverseIds []interface{} `json:"multiverse_ids"`
|
||||
Name string `json:"name"`
|
||||
Nonfoil bool `json:"nonfoil"`
|
||||
Object string `json:"object"`
|
||||
OracleID string `json:"oracle_id"`
|
||||
OracleText string `json:"oracle_text"`
|
||||
Oversized bool `json:"oversized"`
|
||||
Prices struct {
|
||||
Eur interface{} `json:"eur"`
|
||||
EurFoil interface{} `json:"eur_foil"`
|
||||
Tix interface{} `json:"tix"`
|
||||
Usd interface{} `json:"usd"`
|
||||
UsdEtched interface{} `json:"usd_etched"`
|
||||
UsdFoil interface{} `json:"usd_foil"`
|
||||
} `json:"prices"`
|
||||
PrintedName string `json:"printed_name"`
|
||||
PrintedText string `json:"printed_text"`
|
||||
PrintedTypeLine string `json:"printed_type_line"`
|
||||
PrintsSearchURI string `json:"prints_search_uri"`
|
||||
Promo bool `json:"promo"`
|
||||
PurchaseUris struct {
|
||||
Cardhoarder string `json:"cardhoarder"`
|
||||
Cardmarket string `json:"cardmarket"`
|
||||
Tcgplayer string `json:"tcgplayer"`
|
||||
} `json:"purchase_uris"`
|
||||
Rarity string `json:"rarity"`
|
||||
RelatedUris struct {
|
||||
Edhrec string `json:"edhrec"`
|
||||
Mtgtop8 string `json:"mtgtop8"`
|
||||
TcgplayerInfiniteArticles string `json:"tcgplayer_infinite_articles"`
|
||||
TcgplayerInfiniteDecks string `json:"tcgplayer_infinite_decks"`
|
||||
} `json:"related_uris"`
|
||||
ReleasedAt string `json:"released_at"`
|
||||
Reprint bool `json:"reprint"`
|
||||
Reserved bool `json:"reserved"`
|
||||
RulingsURI string `json:"rulings_uri"`
|
||||
ScryfallSetURI string `json:"scryfall_set_uri"`
|
||||
ScryfallURI string `json:"scryfall_uri"`
|
||||
Set string `json:"set"`
|
||||
SetID string `json:"set_id"`
|
||||
SetName string `json:"set_name"`
|
||||
SetSearchURI string `json:"set_search_uri"`
|
||||
SetType string `json:"set_type"`
|
||||
SetURI string `json:"set_uri"`
|
||||
StorySpotlight bool `json:"story_spotlight"`
|
||||
Textless bool `json:"textless"`
|
||||
TypeLine string `json:"type_line"`
|
||||
URI string `json:"uri"`
|
||||
Variation bool `json:"variation"`
|
||||
}
|
||||
|
||||
func fetch(path string) *Card {
|
||||
resp, err := http.Get(fmt.Sprintf("https://api.scryfall.com/cards/%s/", path))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
//We Read the response body on the line below.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
r := bytes.NewReader(body)
|
||||
decoder := json.NewDecoder(r)
|
||||
val := &Card{}
|
||||
err = decoder.Decode(val)
|
||||
return val
|
||||
}
|
||||
6
src/archivar/set.go
Normal file
6
src/archivar/set.go
Normal file
@ -0,0 +1,6 @@
|
||||
package archivar
|
||||
|
||||
type Set struct {
|
||||
Description string `description`
|
||||
Cards []string `cards`
|
||||
}
|
||||
32
src/archivar/setfile.go
Normal file
32
src/archivar/setfile.go
Normal file
@ -0,0 +1,32 @@
|
||||
package archivar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Setfile struct {
|
||||
Description string `description`
|
||||
Cards []string `cards`
|
||||
}
|
||||
|
||||
// Read formatted yaml file
|
||||
func (c *Setfile) ReadFile(path string) *Setfile {
|
||||
|
||||
yamlFile, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
LogMessage("Could not open file", "red")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(yamlFile, c)
|
||||
if err != nil {
|
||||
LogMessage(fmt.Sprintf("Unmarshal %v", err), "red")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
29
src/archivar/start.go
Normal file
29
src/archivar/start.go
Normal file
@ -0,0 +1,29 @@
|
||||
package archivar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
version string = "0.0.1"
|
||||
)
|
||||
|
||||
// Main Wrapper for a set of tests
|
||||
func Start(set_file string) {
|
||||
|
||||
var s Setfile
|
||||
s.ReadFile(set_file)
|
||||
|
||||
LogMessage(fmt.Sprintf("Archivar %v\n", version), "green")
|
||||
|
||||
fmt.Printf("Your Challenge: %s\n", s.Description)
|
||||
|
||||
// Loop over different challenges
|
||||
for _, entry := range s.Cards {
|
||||
card := fetch(entry)
|
||||
fmt.Println(card)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
23
src/archivar/utils.go
Normal file
23
src/archivar/utils.go
Normal file
@ -0,0 +1,23 @@
|
||||
package archivar
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
challengeLimiter string = ">> "
|
||||
colorCyan string = "\033[36m"
|
||||
colorGreen string = "\033[32m"
|
||||
colorPurple string = "\033[35m"
|
||||
colorRed string = "\033[31m"
|
||||
colorReset string = "\033[0m"
|
||||
)
|
||||
|
||||
// Colored output on commandline
|
||||
func LogMessage(message string, color string) {
|
||||
if color == "red" {
|
||||
fmt.Printf("%s%s%s\n", colorRed, message, colorReset)
|
||||
} else if color == "green" {
|
||||
fmt.Printf("%s%s%s\n", colorGreen, message, colorReset)
|
||||
} else {
|
||||
fmt.Printf("%s\n", message)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user