Debian Codegraph @

examples/demo.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4
5 # Import https://github.com/bwplotka/demo-nav bash library.
6 TYPE_SPEED=40
7 IMMEDIATE_REVEAL=false
8 NUMS=false
9 PREFIX="➜ "
10 curl https://raw.githubusercontent.com/bwplotka/demo-nav/master/demo-nav.sh -o ${DIR}/demo-nav.sh
11 . "${DIR}/demo-nav.sh"
12
13 rm -rf ${DIR}/tmp-demo
14 mkdir ${DIR}/tmp-demo
15 cp -r ${DIR}/../testdata/go.* ${DIR}/tmp-demo
16 cp -r ${DIR}/../testdata/main.go ${DIR}/tmp-demo
17 cd ${DIR}/tmp-demo
18
19 clear
20
21 # `r` registers command to be invoked.
22 #
23 # First argument specifies what should be printed.
24 # Second argument specifies what will be actually executed.
25 #
26 # NOTE: Use `'` to quote strings inside command.
27 r "${RED}# 'bingo' Demo time!"
28 r "${YELLOW}# Let's start with simple dev project (e.g Go project):" "ls -l"
29 r "${GREEN}export GOBIN=\`pwd\`/.bin && export PATH=\${PATH}:\${GOBIN} ${YELLOW}# We are exporting GOBIN envvar that controls where the binaries will be built."
30 r "${YELLOW}# Let's install 'bingo' (Go 1.14+ required):"
31 r "${GREEN}go get -u github.com/bwplotka/bingo"
32 r "${YELLOW}# Let's say we want to have proper lint tool, just 'bingo get' it!"
33 r "${GREEN}bingo get github.com/golangci/golangci-lint/cmd/golangci-lint"
34 r "${GREEN}ls -l .bingo"
35 r "${YELLOW}# As we can see above, 'bingo' created .bingo directory which stores separate .mod file for each pinned binary."
36 r "${GREEN}cat .bingo/golangci-lint.mod"
37 r "${YELLOW}# In fact, this is just standard Go modules with special preserved comments. You can modify it in place as normal Go .mod file!"
38 r "${GREEN}ls -l \${GOBIN}"
39 r "${YELLOW}# We also can see the golangci-lint was installed. NOTE that 'bingo' produces immutable names intentionally."
40 r "${GREEN}bingo list ${YELLOW}# 'bingo' can also list us what tools are pinned."
41 r "${YELLOW}# Let's install exact commit of goimports, 'bingo' can do that too:"
42 r "${GREEN}bingo get golang.org/x/tools/cmd/goimports@688b3c5d9fa5ae5ca974e3c59a6557c26007e0e6"
43 r "${GREEN}ls -l .bingo"
44 r "${GREEN}ls -l \${GOBIN}"
45 r "${GREEN}bingo list"
46 r "${GREEN}bingo get -u goimports ${YELLOW}# This is how your upgrade the pinned tool."
47 r "${GREEN}bingo get [email protected] ${YELLOW}# This is how your downgrade if you need to."
48 r "${GREEN}bingo list"
49 r "${YELLOW}# Let's remove all installed binaries now to simulate freshly cloned repository:"
50 r "${GREEN}rm -rf \${GOBIN}"
51 r "${YELLOW}# Now, to install ALL required tools you can either use single 'bingo' command:"
52 r "${GREEN}go get github.com/bwplotka/bingo && bingo get && ls -l \${GOBIN}"
53 r "${YELLOW}# ...or if you don't want to depend on bingo for read access of you repo, just Go build command (no 'bingo' required):"
54 r "${GREEN}rm -rf \${GOBIN}"
55 r "${GREEN}go build -modfile=.bingo/golangci-lint.mod -o=\${GOBIN}/golangci-lint-v1.23.7 github.com/golangci/golangci-lint/cmd/golangci-lint && ls -l \${GOBIN}"
56 r "${YELLOW}# Thanks! See https://github.com/bwplotka/bingo for details. Demo created with https://github.com/bwplotka/demo-nav."
57
58 # Last entry to run navigation mode.
59 navigate