├── .gitignore ├── .go-version ├── .goxc.json ├── .travis.yml ├── CHANGELOG.md ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── gig.json ├── gig ├── config.go ├── const.go ├── gig.go ├── gig_test.go └── list.go ├── main.go ├── scripts ├── _scoop.sh ├── bumpup.sh ├── formula.sh ├── packages.sh ├── test.sh ├── tweet.sh └── upload.sh └── version.go /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/0c5ace9de99c220bb69012581d68ca6fa977449b/Go.gitignore 2 | 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, build with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | *coverage.txt 16 | 17 | # dep 18 | vendor/ 19 | 20 | # artifacts 21 | dist/ 22 | gig_formula.rb 23 | 24 | # IDE 25 | .idea 26 | 27 | -------------------------------------------------------------------------------- /.go-version: -------------------------------------------------------------------------------- 1 | 1.10.3 2 | -------------------------------------------------------------------------------- /.goxc.json: -------------------------------------------------------------------------------- 1 | { 2 | "ArtifactsDest": "dist", 3 | "Tasks": [ 4 | "clean-destination", 5 | "xc", 6 | "archive-zip", 7 | "rmbin" 8 | ], 9 | "TaskSettings": { 10 | "archive-zip": { 11 | "include-top-level-dir": "windows darwin linux", 12 | "platforms": "windows darwin linux" 13 | } 14 | }, 15 | "Arch": "386 amd64", 16 | "Os": "linux darwin windows", 17 | "ConfigVersion": "0.9" 18 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | 5 | go: 6 | - 1.10 7 | 8 | os: 9 | - osx 10 | 11 | before_install: 12 | - go get -u github.com/golang/dep/cmd/dep 13 | - dep ensure 14 | 15 | script: 16 | - make test-all 17 | 18 | after_success: 19 | - bash <(curl -s https://codecov.io/bash) 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [v0.1.5](https://github.com/toshi0607/gig/compare/v0.1.4...v0.1.5) (2018-06-09) 4 | 5 | * :up: go 1.10.3 [#17](https://github.com/toshi0607/gig/pull/17) ([toshi0607](https://github.com/toshi0607)) 6 | * :green_heart: tweet latest release [#16](https://github.com/toshi0607/gig/pull/16) ([toshi0607](https://github.com/toshi0607)) 7 | * :green_heart: add task for errcheck [#15](https://github.com/toshi0607/gig/pull/15) ([toshi0607](https://github.com/toshi0607)) 8 | * :bug: fix scoop script [#14](https://github.com/toshi0607/gig/pull/14) ([toshi0607](https://github.com/toshi0607)) 9 | 10 | ## [v0.1.4](https://github.com/toshi0607/gig/compare/v0.1.3...v0.1.4) (2018-05-16) 11 | 12 | 13 | ## [v0.1.3](https://github.com/toshi0607/gig/compare/v0.1.2...v0.1.3) (2018-05-16) 14 | 15 | * :bug: show help properly [#13](https://github.com/toshi0607/gig/pull/13) ([toshi0607](https://github.com/toshi0607)) 16 | * :green_heart: add script for scoop [#12](https://github.com/toshi0607/gig/pull/12) ([toshi0607](https://github.com/toshi0607)) 17 | * :bug: update scoop file [#11](https://github.com/toshi0607/gig/pull/11) ([toshi0607](https://github.com/toshi0607)) 18 | 19 | ## [v0.1.2](https://github.com/toshi0607/gig/compare/v0.1.1...v0.1.2) (2018-05-13) 20 | 21 | * :bug: show help without error [#10](https://github.com/toshi0607/gig/pull/10) ([toshi0607](https://github.com/toshi0607)) 22 | * :bug: add extract_dir property [#9](https://github.com/toshi0607/gig/pull/9) ([toshi0607](https://github.com/toshi0607)) 23 | * :tada: Scoopでインストール対応 [#8](https://github.com/toshi0607/gig/pull/8) ([toshi0607](https://github.com/toshi0607)) 24 | 25 | ## [v0.1.1](https://github.com/toshi0607/gig/compare/v0.0.6...v0.1.1) (2018-05-13) 26 | 27 | * :green_heart: output formula [#7](https://github.com/toshi0607/gig/pull/7) ([toshi0607](https://github.com/toshi0607)) 28 | 29 | ## [v0.0.3](https://github.com/toshi0607/gig/compare/v0.0.2...v0.0.3) (2018-05-13) 30 | 31 | * add release script [#6](https://github.com/toshi0607/gig/pull/6) ([toshi0607](https://github.com/toshi0607)) 32 | 33 | ## [v0.0.2](https://github.com/toshi0607/gig/compare/v0.0.1...v0.0.2) (2018-05-13) 34 | 35 | * add coverage [#5](https://github.com/toshi0607/gig/pull/5) ([toshi0607](https://github.com/toshi0607)) 36 | * CI整備 [#4](https://github.com/toshi0607/gig/pull/4) ([toshi0607](https://github.com/toshi0607)) 37 | * :up: errors [#3](https://github.com/toshi0607/gig/pull/3) ([toshi0607](https://github.com/toshi0607)) 38 | * add error info [#2](https://github.com/toshi0607/gig/pull/2) ([toshi0607](https://github.com/toshi0607)) 39 | * Fix typo in README [#1](https://github.com/toshi0607/gig/pull/1) ([zaneli](https://github.com/zaneli)) 40 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/PuerkitoBio/goquery" 6 | packages = ["."] 7 | revision = "a86ea073017a6beddef78c8659e7224e8ca634b0" 8 | version = "v1.4.0" 9 | 10 | [[projects]] 11 | name = "github.com/andybalholm/cascadia" 12 | packages = ["."] 13 | revision = "901648c87902174f774fac311d7f176f8647bdaa" 14 | version = "v1.0.0" 15 | 16 | [[projects]] 17 | name = "github.com/jessevdk/go-flags" 18 | packages = ["."] 19 | revision = "c6ca198ec95c841fdb89fc0de7496fed11ab854e" 20 | version = "v1.4.0" 21 | 22 | [[projects]] 23 | name = "github.com/pkg/errors" 24 | packages = ["."] 25 | revision = "645ef00459ed84a119197bfb8d8205042c6df63d" 26 | version = "v0.8.0" 27 | 28 | [[projects]] 29 | branch = "master" 30 | name = "golang.org/x/net" 31 | packages = [ 32 | "html", 33 | "html/atom" 34 | ] 35 | revision = "5f9ae10d9af5b1c89ae6904293b14b064d4ada23" 36 | 37 | [solve-meta] 38 | analyzer-name = "dep" 39 | analyzer-version = 1 40 | inputs-digest = "aa4ee99581bcede628d5822c4a6f3ce6679ce69a2847d14293764812023aaaf6" 41 | solver-name = "gps-cdcl" 42 | solver-version = 1 43 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | [[constraint]] 2 | name = "github.com/PuerkitoBio/goquery" 3 | version = "1.4.0" 4 | 5 | [[constraint]] 6 | name = "github.com/jessevdk/go-flags" 7 | version = "1.4.0" 8 | 9 | [prune] 10 | go-tests = true 11 | unused-packages = true 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 toshi0607 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PACKAGES = $(shell ./scripts/packages.sh) 2 | 3 | EXTERNAL_TOOLS = \ 4 | github.com/golang/dep/cmd/dep \ 5 | github.com/laher/goxc \ 6 | github.com/motemen/gobump \ 7 | github.com/tcnksm/ghr \ 8 | github.com/Songmu/ghch/cmd/ghch 9 | 10 | setup: 11 | @for tool in $(EXTERNAL_TOOLS) ; do \ 12 | echo "Installing $$tool" ; \ 13 | go get $$tool; \ 14 | done 15 | 16 | test-all: vet lint test 17 | 18 | test: 19 | ./scripts/test.sh 20 | 21 | vet: 22 | go vet $(PACKAGES) 23 | 24 | lint: 25 | @if [ -z `which errcheck 2> /dev/null` ]; then \ 26 | go get -u github.com/golang/lint/golint; \ 27 | fi 28 | echo $(PACKAGES) | xargs -n 1 golint -set_exit_status 29 | 30 | errcheck: 31 | @if [ -z `which errcheck 2> /dev/null` ]; then \ 32 | go get -u github.com/kisielk/errcheck; \ 33 | fi 34 | echo $(PACKAGES) | xargs errcheck -ignoretests 35 | 36 | release: bump upload formula tweet 37 | 38 | bump: setup 39 | ./scripts/bumpup.sh 40 | 41 | upload: bump 42 | ./scripts/upload.sh 43 | 44 | formula: upload 45 | ./scripts/formula.sh 46 | 47 | tweet: upload 48 | ./scripts/tweet.sh 49 | 50 | .PHONY: test-all test vet lint setup release bump upload formula tweet 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gig 2 | ==== 3 | 4 | [![Build Status](https://travis-ci.org/toshi0607/gig.svg?branch=master)](https://travis-ci.org/toshi0607/gig) 5 | [![Go Report Card](https://goreportcard.com/badge/github.com/toshi0607/gig)](https://goreportcard.com/report/github.com/toshi0607/gig) 6 | [![MIT License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/toshi0607/gig/blob/master/LICENSE) 7 | [![Codecov](https://codecov.io/github/toshi0607/gig/coverage.svg?branch=master)](https://codecov.io/github/toshi0607/gig?branch=master) 8 | 9 | ## Description 10 | generate (or output) .gitignore using [github/gitignore](https://github.com/github/gitignore) 11 | 12 | ## Demo 13 | ![](https://user-images.githubusercontent.com/7035446/39394981-84cef0aa-4b13-11e8-86b9-7af4f979efa3.gif) 14 | 15 | ## VS. 16 | 17 | ### gibo 18 | [simonwhitaker/gibo](https://github.com/simonwhitaker/gibo) is useful tool for .gitinore. 19 | It does `git clone` the templates from [github/gitignore](https://github.com/github/gitignore) and it uses local files. 20 | So the gibo is fast, but you have to update local files to use tha latest template. 21 | 22 | ### gig 23 | [toshi0607/gig](https://github.com/toshi0607/gig) is also a tool for .gitinore. 24 | The gig always use the latest template by accessing github each time. 25 | So you don't have to update something manually. 26 | 27 | ## Requirement 28 | if you build gig loccally, please exec this command first. 29 | 30 | ```sh 31 | $ dep ensure 32 | ``` 33 | 34 | ## Usage 35 | 36 | ``` 37 | Usage: 38 | gig [OPTIONS] [Language] 39 | 40 | Application Options: 41 | -l, --list Show list of available language 42 | -f, --File Output .gitignore file 43 | -q, --quiet Hide stdout 44 | -v, --version Show version 45 | 46 | Help Options: 47 | -h, --help Show this help message 48 | ``` 49 | 50 | ### Example 51 | 52 | ```sh 53 | # show available languages 54 | $ gig -l 55 | Actionscript 56 | Ada 57 | Agda 58 | Android 59 | ... 60 | 61 | 62 | # search available languages like go 63 | $ gig -l | grep -i go 64 | Go 65 | Godot 66 | IGORPro 67 | 68 | 69 | # output to the .gitignore file 70 | $ gig Ruby -f 71 | $ cat .gitignore 72 | *.gem 73 | *.rbc 74 | /.config 75 | /coverage/ 76 | ... 77 | 78 | 79 | # add to the existing .gitignore file 80 | $ gig Go >> .gitignore 81 | $ cat .gitignore 82 | ... 83 | # Binaries for programs and plugins 84 | *.exe 85 | *.exe~ 86 | ... 87 | 88 | ``` 89 | 90 | ### Tips 91 | 92 | [peco](https://github.com/peco/peco) 's incremental search helps gig a lot. 93 | 94 | ```sh 95 | $ gig $(gig -l | peco) 96 | ``` 97 | 98 | ![](https://user-images.githubusercontent.com/7035446/39398424-86087f74-4b48-11e8-9428-6f771ac8074b.gif) 99 | 100 | Setting alias like blow to your dotfile (.bashrc, .zshrc, etc) is also useful. 101 | 102 | ```sh 103 | alias pgig='gig $(gig -l | peco)' 104 | ``` 105 | 106 | ## Install 107 | 108 | ### for Homebrew (macOS, linux) 109 | 110 | ```sh 111 | $ brew tap toshi0607/homebrew-gig 112 | $ brew install gig 113 | ``` 114 | 115 | ### for Go environment 116 | 117 | ```sh 118 | $ go get -u github.com/toshi0607/gig 119 | ``` 120 | 121 | ### for Scoop (Windows) 122 | 123 | ``` 124 | $ scoop install https://raw.githubusercontent.com/toshi0607/gig/master/gig.json 125 | ``` 126 | 127 | ### for others 128 | You can download the binary directly from [latest release](https://github.com/toshi0607/gig/releases/latest) 129 | 130 | * gig_darwin_386.zip 131 | * gig_darwin_amd64.zip 132 | * gig_linux_386.zip 133 | * gig_linux_amd64.zip 134 | * gig_windows_386.zip 135 | * gig_windows_amd64.zip 136 | 137 | ## Contribution 138 | 139 | 1. Fork ([https://github.com/toshi0607/gig/fork](https://github.com/toshi0607/gig/fork)) 140 | 1. Create a feature branch 141 | 1. Commit your changes 142 | 1. Run test suite with the `make test` command and confirm that it passes 143 | 1. Run `gofmt -s` 144 | 1. Create new Pull Request 145 | 146 | ## Licence 147 | [MIT](LICENSE) file for details. 148 | 149 | ## Author 150 | 151 | * [GitHub](https://github.com/toshi0607) 152 | * [twitter](https://twitter.com/toshi0607) 153 | -------------------------------------------------------------------------------- /gig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.5", 3 | "architecture": { 4 | "64bit": { 5 | "url": "https://github.com/toshi0607/gig/releases/download/v0.1.5/gig_windows_amd64.zip", 6 | "bin": "gig.exe", 7 | "extract_dir": "gig_windows_amd64" 8 | }, 9 | "32bit": { 10 | "url": "https://github.com/toshi0607/gig/releases/download/v0.1.5/gig_windows_386.zip", 11 | "bin": "gig.exe", 12 | "extract_dir": "gig_windows_386" 13 | } 14 | }, 15 | "homepage": "https://github.com/toshi0607/gig" 16 | } 17 | -------------------------------------------------------------------------------- /gig/config.go: -------------------------------------------------------------------------------- 1 | package gig 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/jessevdk/go-flags" 7 | "github.com/pkg/errors" 8 | ) 9 | 10 | type config struct { 11 | List bool `short:"l" long:"list" description:"Show list of available language"` 12 | File bool `short:"f" long:"File" description:"Output .gitignore file"` 13 | Quiet bool `short:"q" long:"quiet" description:"Hide stdout"` 14 | Version bool `short:"v" long:"version" description:"Show version"` 15 | Help bool `short:"h" long:"help" description:"Show this help message"` 16 | Args struct { 17 | Language string 18 | } `positional-args:"yes"` 19 | } 20 | 21 | func (g *Gig) initConfig() error { 22 | p := flags.NewParser(&g.Config, flags.None) 23 | _, err := p.Parse() 24 | if err != nil { 25 | return errors.Wrapf(err, "failed to parse. Config: %s", &g.Config) 26 | } 27 | 28 | if g.Config.Version { 29 | return fmt.Errorf("gig version %s", g.Version) 30 | } 31 | 32 | if g.Config.Help || 33 | (!g.Config.List && g.Config.Args.Language == "") { 34 | p.WriteHelp(g.ErrStream) 35 | return errors.New("") 36 | } 37 | 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /gig/const.go: -------------------------------------------------------------------------------- 1 | package gig 2 | 3 | const ( 4 | gitignoreBaseURL = "https://github.com/github/gitignore" 5 | gitignoreFileBaseURL = "https://raw.githubusercontent.com/github/gitignore/master/" 6 | gitignoreExt = ".gitignore" 7 | ) 8 | -------------------------------------------------------------------------------- /gig/gig.go: -------------------------------------------------------------------------------- 1 | package gig 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | "os" 8 | ) 9 | 10 | // Gig is the body of the cli 11 | type Gig struct { 12 | OutStream, ErrStream io.Writer 13 | Output []io.Writer 14 | Version string 15 | Config config 16 | } 17 | 18 | // Run executes gig's functions 19 | func (g *Gig) Run() int { 20 | err := g.initConfig() 21 | if err != nil { 22 | fmt.Fprintln(g.ErrStream, err) 23 | return 1 24 | } 25 | 26 | if g.Config.List { 27 | err := g.showList() 28 | if err != nil { 29 | fmt.Fprintln(g.ErrStream, err) 30 | return 1 31 | } 32 | return 0 33 | } 34 | 35 | if g.Config.File { 36 | var writer io.WriteCloser 37 | writer, err := os.Create(gitignoreExt) 38 | if err != nil { 39 | fmt.Fprintln(g.ErrStream, err) 40 | return 1 41 | } 42 | g.Output = append(g.Output, writer) 43 | defer writer.Close() 44 | } 45 | if !g.Config.Quiet { 46 | g.Output = append(g.Output, os.Stdout) 47 | } 48 | 49 | lang := g.Config.Args.Language 50 | url := gitignoreFileBaseURL + lang + gitignoreExt 51 | resp, err := http.Get(url) 52 | if err != nil { 53 | fmt.Fprintln(g.ErrStream, err) 54 | return 1 55 | } 56 | defer resp.Body.Close() 57 | 58 | dest := io.MultiWriter(g.Output...) 59 | _, err = io.Copy(dest, resp.Body) 60 | if err != nil { 61 | fmt.Fprintln(g.ErrStream, err) 62 | return 1 63 | } 64 | return 0 65 | } 66 | -------------------------------------------------------------------------------- /gig/gig_test.go: -------------------------------------------------------------------------------- 1 | package gig 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "os" 8 | "strings" 9 | "testing" 10 | ) 11 | 12 | func Test_Run(t *testing.T) { 13 | tests := []struct { 14 | args []string 15 | containing []string 16 | expectedCode int 17 | }{ 18 | {[]string{"output gitignore", "Go", "-q"}, []string{"# Test binary, build with `go test -c`"}, 0}, 19 | {[]string{"output gitignore", "Ruby", "-q"}, []string{"*.gem"}, 0}, 20 | {[]string{"output gitignore", "C++", "-q"}, []string{"# Compiled Static libraries"}, 0}, 21 | {[]string{"shows list", "-l"}, []string{"Go", "Rails", "Kotlin"}, 0}, 22 | {[]string{"shows version", "-v"}, []string{"gig version"}, 1}, 23 | {[]string{"shows usage", "-q"}, []string{"Usage:"}, 1}, 24 | {[]string{"shows help", "-h"}, []string{"Usage:"}, 1}, 25 | } 26 | 27 | for _, te := range tests { 28 | stream := new(bytes.Buffer) 29 | cli := &Gig{OutStream: stream, ErrStream: stream, Output: []io.Writer{stream}} 30 | os.Args = te.args 31 | status := cli.Run() 32 | 33 | if status != te.expectedCode { 34 | t.Errorf("ExitStatus=%d, want %d", status, te.expectedCode) 35 | } 36 | 37 | for _, v := range te.containing { 38 | containing := fmt.Sprintf(v) 39 | if !strings.Contains(stream.String(), containing) { 40 | t.Errorf("[%s] actual: %s, want: %s", te.args[0], stream.String(), containing) 41 | } 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /gig/list.go: -------------------------------------------------------------------------------- 1 | package gig 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | "net/url" 8 | "strings" 9 | 10 | "github.com/PuerkitoBio/goquery" 11 | "github.com/pkg/errors" 12 | ) 13 | 14 | func (g *Gig) showList() error { 15 | resp, err := http.Get(gitignoreBaseURL) 16 | if err != nil { 17 | return errors.Wrapf(err, "failed to access URL: %s", gitignoreBaseURL) 18 | } 19 | defer resp.Body.Close() 20 | 21 | langCh := make(chan string) 22 | go func() { 23 | getLang(resp.Body, langCh) 24 | close(langCh) 25 | }() 26 | 27 | for v := range langCh { 28 | decoded, err := url.QueryUnescape(v) 29 | if err != nil { 30 | return errors.Wrapf(err, "failed to unescape: %s", v) 31 | } 32 | fmt.Fprintln(g.OutStream, decoded) 33 | } 34 | 35 | return nil 36 | } 37 | 38 | func getLang(r io.Reader, ch chan string) error { 39 | doc, err := goquery.NewDocumentFromReader(r) 40 | if err != nil { 41 | return errors.Wrap(err, "failed to get document") 42 | } 43 | 44 | doc.Find("a").Each(func(_ int, s *goquery.Selection) { 45 | url, ok := s.Attr("href") 46 | if ok && strings.HasSuffix(url, gitignoreExt) { 47 | ch <- extractLang(url) 48 | } 49 | }) 50 | return nil 51 | } 52 | 53 | func extractLang(s string) string { 54 | str := strings.Split(s, "/") 55 | return strings.Replace(str[len(str)-1], gitignoreExt, "", -1) 56 | } 57 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/toshi0607/gig/gig" 8 | ) 9 | 10 | func main() { 11 | defer func() { 12 | if err := recover(); err != nil { 13 | fmt.Fprintf(os.Stderr, "Error:\n%s\n", err) 14 | os.Exit(1) 15 | } 16 | }() 17 | cli := &gig.Gig{OutStream: os.Stdout, ErrStream: os.Stderr, Version: version} 18 | os.Exit(cli.Run()) 19 | } 20 | -------------------------------------------------------------------------------- /scripts/_scoop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | ROOT_DIR=$(cd $(dirname $0) && cd .. && pwd) 5 | VERSION=$(gobump show -r) 6 | 7 | cat << EOF > ${ROOT_DIR}/gig.json 8 | { 9 | "version": "${VERSION}", 10 | "architecture": { 11 | "64bit": { 12 | "url": "https://github.com/toshi0607/gig/releases/download/v${VERSION}/gig_windows_amd64.zip", 13 | "bin": "gig.exe", 14 | "extract_dir": "gig_windows_amd64" 15 | }, 16 | "32bit": { 17 | "url": "https://github.com/toshi0607/gig/releases/download/v${VERSION}/gig_windows_386.zip", 18 | "bin": "gig.exe", 19 | "extract_dir": "gig_windows_386" 20 | } 21 | }, 22 | "homepage": "https://github.com/toshi0607/gig" 23 | } 24 | EOF 25 | -------------------------------------------------------------------------------- /scripts/bumpup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | ROOT_DIR=$(cd $(dirname $0) && cd .. && pwd) 5 | 6 | echo current version: $(gobump show -r) 7 | read -p "input next version: " next_version 8 | 9 | gobump set $next_version -w 10 | ghch -w -N v$next_version 11 | 12 | ${ROOT_DIR}/scripts/_scoop.sh 13 | 14 | git add version.go CHANGELOG.md gig.json 15 | git commit -m "Checking in changes prior to tagging of version v$next_version" 16 | git tag v$next_version 17 | git push && git push --tags 18 | -------------------------------------------------------------------------------- /scripts/formula.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | ROOT_DIR=$(cd $(dirname $0) && cd .. && pwd) 5 | ARTIFACTS_DIR=${ROOT_DIR}/dist/snapshot 6 | PACKAGE=gig 7 | PACKAGE_FULL=github.com/toshi0607/${PACKAGE} 8 | FORMULA_CLASS=Gig 9 | VERSION=$(gobump show -r) 10 | TAG=v${VERSION} 11 | 12 | shasum256() { 13 | local os=${1} 14 | local arch=${2} 15 | 16 | shasum -a 256 ${ARTIFACTS_DIR}/${PACKAGE}_${os}_${arch}.zip | awk '{print $1}' 17 | } 18 | 19 | formula(){ 20 | cat << EOF > ${PACKAGE}_formula.rb 21 | class ${FORMULA_CLASS} < Formula 22 | homepage 'https://${PACKAGE_FULL}' 23 | version '${VERSION}' 24 | 25 | if Hardware::CPU.is_32_bit? 26 | if OS.linux? 27 | url 'https://${PACKAGE_FULL}/releases/download/${TAG}/${PACKAGE}_linux_386.zip' 28 | sha256 '$(shasum256 linux 386)' 29 | else 30 | url 'https://${PACKAGE_FULL}/releases/download/${TAG}/${PACKAGE}_darwin_386.zip' 31 | sha256 '$(shasum256 darwin 386)' 32 | end 33 | else 34 | if OS.linux? 35 | url 'https://${PACKAGE_FULL}/releases/download/${TAG}/${PACKAGE}_linux_amd64.zip' 36 | sha256 '$(shasum256 linux amd64)' 37 | else 38 | url 'https://${PACKAGE_FULL}/releases/download/${TAG}/${PACKAGE}_darwin_amd64.zip' 39 | sha256 '$(shasum256 darwin amd64)' 40 | end 41 | end 42 | 43 | def install 44 | bin.install '${PACKAGE}' 45 | end 46 | end 47 | EOF 48 | } 49 | 50 | formula 51 | -------------------------------------------------------------------------------- /scripts/packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | 4 | echo "$(go list ./... | \grep -v 'vendor')" 5 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | 4 | SCRIPTS=$(cd $(dirname $0) && pwd) 5 | 6 | echo "" > coverage.txt 7 | for d in $(${SCRIPTS}/packages.sh); do 8 | go test -race -coverprofile=profile.out -covermode=atomic $d 9 | if [ -f profile.out ]; then 10 | cat profile.out >> coverage.txt 11 | rm profile.out 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /scripts/tweet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | 4 | curl -X POST -d '{"owner": "toshi0607", "repo": "gig"}' ${RELEASE_TWEETER_ENDPOINT} 5 | -------------------------------------------------------------------------------- /scripts/upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | # set GITHUB_TOKEN=... 5 | 6 | latest_tag=$(git describe --abbrev=0 --tags) 7 | goxc 8 | ghr -u toshi0607 -r gig $latest_tag dist/snapshot/ 9 | -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const version = "0.1.5" 4 | --------------------------------------------------------------------------------