Skip to content

Commit a45744a

Browse files
authored
Merge pull request #164 from blacknon/develop_0.9.0
Version 0.9.0
2 parents 0ba5e4d + 2ada87a commit a45744a

File tree

432 files changed

+67935
-1309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+67935
-1309
lines changed

.github/workflows/demo-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- name: Run demo e2e test
2525
env:
2626
LSSH_RUN_DEMO_E2E: "1"
27-
run: go test -v ./demo -run TestDemoDockerComposeE2E
27+
run: sudo modprobe fuse && go test -v ./demo -run TestDemoDockerComposeE2E

.github/workflows/release.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ jobs:
7676
ext=".exe"
7777
fi
7878
79-
for cmd in lssh lscp lsftp lsmon lsshell; do
79+
cmds="lssh lscp lsftp lssync lsdiff lsmon lsshell lsmux lspipe"
80+
if [ "${GOOS}" != "windows" ]; then
81+
cmds="${cmds} lsshfs"
82+
fi
83+
84+
for cmd in ${cmds}; do
8085
go build -o "dist/bin/${cmd}${ext}" "./cmd/${cmd}"
8186
done
8287
@@ -105,19 +110,37 @@ jobs:
105110
case "$1" in
106111
full) echo "Full lssh suite with SSH, transfer, monitoring, and parallel shell tools." ;;
107112
core) echo "Core SSH client package for the lssh suite." ;;
108-
transfer) echo "Transfer tools package for the lssh suite, including lscp and lsftp." ;;
113+
transfer)
114+
if [ "$GOOS" = "windows" ]; then
115+
echo "Transfer and diff tools package for the lssh suite, including lscp, lsftp, lssync, and lsdiff."
116+
else
117+
echo "Transfer, diff, and mount tools package for the lssh suite, including lscp, lsftp, lssync, lsdiff, and lsshfs."
118+
fi
119+
;;
109120
monitor) echo "Monitoring tools package for the lssh suite, including lsmon." ;;
110-
sysadmin) echo "Sysadmin tools package for the lssh suite, including lsshell." ;;
121+
sysadmin) echo "Sysadmin tools package for the lssh suite, including lsshell, lsmux, and lspipe." ;;
111122
esac
112123
}
113124
114125
package_binaries() {
115126
case "$1" in
116-
full) echo "lssh lscp lsftp lsmon lsshell" ;;
127+
full)
128+
if [ "$GOOS" = "windows" ]; then
129+
echo "lssh lscp lsftp lssync lsdiff lsmon lsshell lsmux lspipe"
130+
else
131+
echo "lssh lscp lsftp lssync lsdiff lsshfs lsmon lsshell lsmux lspipe"
132+
fi
133+
;;
117134
core) echo "lssh" ;;
118-
transfer) echo "lscp lsftp" ;;
135+
transfer)
136+
if [ "$GOOS" = "windows" ]; then
137+
echo "lscp lsftp lssync lsdiff"
138+
else
139+
echo "lscp lsftp lssync lsdiff lsshfs"
140+
fi
141+
;;
119142
monitor) echo "lsmon" ;;
120-
sysadmin) echo "lsshell" ;;
143+
sysadmin) echo "lsshell lsmux lspipe" ;;
121144
esac
122145
}
123146

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
/lsmon
2121
/lsmux
2222
/lsshell
23+
/lsshfs
2324
/lssync
25+
/lsdiff
26+
/lspipe
2427
*.exe

Makefile

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,34 @@ GOTEST=$(MODULE) $(GOCMD) test -cover
77
GOGET=$(GOCMD) get
88
GOMOD=$(MODULE) $(GOCMD) mod
99
GOINSTALL=$(MODULE) $(GOCMD) install
10+
COMPLETION_SHELL?=all
11+
COMPLETION_PREFIX?=
1012

1113
# OS別にbuildのコマンド生成
1214
UNAME_S=$(shell uname -s)
1315
BUILDCMD_LSSH=$(GOBUILD) ./cmd/lssh
1416
BUILDCMD_LSCP=$(GOBUILD) ./cmd/lscp
1517
BUILDCMD_LSFTP=$(GOBUILD) ./cmd/lsftp
1618
BUILDCMD_LSSYNC=$(GOBUILD) ./cmd/lssync
19+
BUILDCMD_LSDIFF=$(GOBUILD) ./cmd/lsdiff
20+
BUILDCMD_LSSHFS=$(GOBUILD) ./cmd/lsshfs
1721
BUILDCMD_LSMON=$(GOBUILD) ./cmd/lsmon
1822
BUILDCMD_LSSHELL=$(GOBUILD) ./cmd/lsshell
23+
BUILDCMD_LSMUX=$(GOBUILD) ./cmd/lsmux
24+
BUILDCMD_LSPIPE=$(GOBUILD) ./cmd/lspipe
1925

2026
# install path
2127
INSTALL_PATH_LSSH=/usr/local/bin/lssh
2228
INSTALL_PATH_LSCP=/usr/local/bin/lscp
2329
INSTALL_PATH_LSFTP=/usr/local/bin/lsftp
2430
INSTALL_PATH_LSSYNC=/usr/local/bin/lssync
31+
INSTALL_PATH_LSDIFF=/usr/local/bin/lsdiff
32+
INSTALL_PATH_LSSHFS=/usr/local/bin/lsshfs
2533
INSTALL_PATH_LSSHELL=/usr/local/bin/lsshell
2634
INSTALL_PATH_LSMON=/usr/local/bin/lsmon
35+
INSTALL_PATH_LSMUX=/usr/local/bin/lsmux
36+
INSTALL_PATH_LSPIPE=/usr/local/bin/lspipe
37+
2738
build:
2839
# Remove unnecessary dependent libraries
2940
$(GOMOD) tidy
@@ -38,39 +49,120 @@ build:
3849
$(BUILDCMD_LSFTP)
3950
# Build lssync
4051
$(BUILDCMD_LSSYNC)
52+
# Build lsdiff
53+
$(BUILDCMD_LSDIFF)
54+
# Build lsshfs
55+
$(BUILDCMD_LSSHFS)
4156
# Build lsmon
4257
$(BUILDCMD_LSMON)
4358
# Build lsshell
4459
$(BUILDCMD_LSSHELL)
60+
# Build lsmux
61+
$(BUILDCMD_LSMUX)
62+
# Build lspipe
63+
$(BUILDCMD_LSPIPE)
4564

4665
clean:
4766
$(GOCLEAN) ./...
4867
rm -f lssh
4968
rm -f lscp
5069
rm -f lsftp
5170
rm -f lssync
71+
rm -f lsdiff
72+
rm -f lsshfs
5273
rm -f lsmon
5374
rm -f lsshell
75+
rm -f lsmux
76+
rm -f lspipe
5477

5578
install:
5679
# rm old binary
5780
[ -e $(INSTALL_PATH_LSSH) ] && rm $(INSTALL_PATH_LSSH) || true
5881
[ -e $(INSTALL_PATH_LSCP) ] && rm $(INSTALL_PATH_LSCP) || true
5982
[ -e $(INSTALL_PATH_LSFTP) ] && rm $(INSTALL_PATH_LSFTP) || true
6083
[ -e $(INSTALL_PATH_LSSYNC) ] && rm $(INSTALL_PATH_LSSYNC) || true
84+
[ -e $(INSTALL_PATH_LSDIFF) ] && rm $(INSTALL_PATH_LSDIFF) || true
85+
[ -e $(INSTALL_PATH_LSSHFS) ] && rm $(INSTALL_PATH_LSSHFS) || true
6186
[ -e $(INSTALL_PATH_LSSHELL) ] && rm $(INSTALL_PATH_LSSHELL) || true
6287
[ -e $(INSTALL_PATH_LSMON) ] && rm $(INSTALL_PATH_LSMON) || true
88+
[ -e $(INSTALL_PATH_LSMUX) ] && rm $(INSTALL_PATH_LSMUX) || true
89+
[ -e $(INSTALL_PATH_LSPIPE) ] && rm $(INSTALL_PATH_LSPIPE) || true
6390

6491
# copy binary to /usr/local/bin/
6592
cp lssh $(INSTALL_PATH_LSSH)
6693
cp lscp $(INSTALL_PATH_LSCP)
6794
cp lsftp $(INSTALL_PATH_LSFTP)
6895
cp lssync $(INSTALL_PATH_LSSYNC)
96+
cp lsdiff $(INSTALL_PATH_LSDIFF)
97+
cp lsshfs $(INSTALL_PATH_LSSHFS)
6998
cp lsshell $(INSTALL_PATH_LSSHELL)
7099
cp lsmon $(INSTALL_PATH_LSMON)
100+
cp lsmux $(INSTALL_PATH_LSMUX)
101+
cp lspipe $(INSTALL_PATH_LSPIPE)
71102

72103
# copy template config file
73104
cp -n example/config.tml ~/.lssh.conf || true
74105

106+
install-completions:
107+
@set -eu; \
108+
shell_name="$(COMPLETION_SHELL)"; \
109+
prefix="$(if $(COMPLETION_PREFIX),$(COMPLETION_PREFIX),/usr/local)"; \
110+
install_shell() { \
111+
src_dir="$$1"; \
112+
dst_dir="$$2"; \
113+
mkdir -p "$$dst_dir"; \
114+
for src in "$$src_dir"/*; do \
115+
[ -f "$$src" ] || continue; \
116+
cp "$$src" "$$dst_dir/"; \
117+
printf 'installed %s -> %s\n' "$$src" "$$dst_dir/"; \
118+
done; \
119+
}; \
120+
case "$$shell_name" in \
121+
bash) install_shell completion/bash "$$prefix/share/bash-completion/completions" ;; \
122+
zsh) install_shell completion/zsh "$$prefix/share/zsh/site-functions" ;; \
123+
fish) install_shell completion/fish "$$prefix/share/fish/vendor_completions.d" ;; \
124+
all) \
125+
install_shell completion/bash "$$prefix/share/bash-completion/completions"; \
126+
install_shell completion/zsh "$$prefix/share/zsh/site-functions"; \
127+
install_shell completion/fish "$$prefix/share/fish/vendor_completions.d"; \
128+
;; \
129+
*) echo "unknown COMPLETION_SHELL: $$shell_name" >&2; exit 1 ;; \
130+
esac
131+
132+
install-completions-user:
133+
@set -eu; \
134+
shell_name="$(COMPLETION_SHELL)"; \
135+
prefix="$(if $(COMPLETION_PREFIX),$(COMPLETION_PREFIX),$$HOME)"; \
136+
install_shell() { \
137+
src_dir="$$1"; \
138+
dst_dir="$$2"; \
139+
mkdir -p "$$dst_dir"; \
140+
for src in "$$src_dir"/*; do \
141+
[ -f "$$src" ] || continue; \
142+
cp "$$src" "$$dst_dir/"; \
143+
printf 'installed %s -> %s\n' "$$src" "$$dst_dir/"; \
144+
done; \
145+
}; \
146+
zsh_note=0; \
147+
case "$$shell_name" in \
148+
bash) install_shell completion/bash "$$prefix/.local/share/bash-completion/completions" ;; \
149+
zsh) install_shell completion/zsh "$$prefix/.zfunc"; zsh_note=1 ;; \
150+
fish) install_shell completion/fish "$$prefix/.config/fish/completions" ;; \
151+
all) \
152+
install_shell completion/bash "$$prefix/.local/share/bash-completion/completions"; \
153+
install_shell completion/zsh "$$prefix/.zfunc"; \
154+
install_shell completion/fish "$$prefix/.config/fish/completions"; \
155+
zsh_note=1; \
156+
;; \
157+
*) echo "unknown COMPLETION_SHELL: $$shell_name" >&2; exit 1 ;; \
158+
esac; \
159+
if [ "$$zsh_note" -eq 1 ]; then \
160+
printf '%s\n' \
161+
'zsh note:' \
162+
' Add this to ~/.zshrc if ~/.zfunc is not already in fpath:' \
163+
' fpath=($$HOME/.zfunc $$fpath)' \
164+
' autoload -Uz compinit && compinit'; \
165+
fi
166+
75167
test:
76168
$(GOTEST) ./...

Makefile_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"strings"
6+
"testing"
7+
)
8+
9+
func TestMakefileIncludesNewCommandsInBuildAndInstall(t *testing.T) {
10+
data, err := os.ReadFile("Makefile")
11+
if err != nil {
12+
t.Fatalf("ReadFile(Makefile) error = %v", err)
13+
}
14+
text := string(data)
15+
16+
for _, needle := range []string{
17+
"BUILDCMD_LSDIFF=$(GOBUILD) ./cmd/lsdiff",
18+
"BUILDCMD_LSSHFS=$(GOBUILD) ./cmd/lsshfs",
19+
"BUILDCMD_LSMUX=$(GOBUILD) ./cmd/lsmux",
20+
"$(BUILDCMD_LSDIFF)",
21+
"$(BUILDCMD_LSSHFS)",
22+
"$(BUILDCMD_LSMUX)",
23+
"cp lsdiff $(INSTALL_PATH_LSDIFF)",
24+
"cp lsshfs $(INSTALL_PATH_LSSHFS)",
25+
"cp lsmux $(INSTALL_PATH_LSMUX)",
26+
"cp lspipe $(INSTALL_PATH_LSPIPE)",
27+
} {
28+
if !strings.Contains(text, needle) {
29+
t.Fatalf("Makefile missing %q", needle)
30+
}
31+
}
32+
}
33+
34+
func TestMakefileCompletionTargetsExist(t *testing.T) {
35+
data, err := os.ReadFile("Makefile")
36+
if err != nil {
37+
t.Fatalf("ReadFile(Makefile) error = %v", err)
38+
}
39+
text := string(data)
40+
for _, target := range []string{"install-completions:", "install-completions-user:"} {
41+
if !strings.Contains(text, target) {
42+
t.Fatalf("Makefile missing target %q", target)
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)