FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sshcode/main.go at master · devbug/sshcode · GitHub
devbug
sshcode
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sshcode
/
main.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
118 lines (97 loc) · 2.57 KB
Breadcrumbs
sshcode
/
main.go
Copy path
File metadata and controls
118 lines (97 loc) · 2.57 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package
main
import
(
"fmt"
"math/rand"
"os"
"strings"
"time"
"github.com/spf13/pflag"
"go.coder.com/cli"
"go.coder.com/flog"
)
func
init
() {
rand
.
Seed
(
time
.
Now
().
Unix
())
}
const
helpTabWidth
=
5
var
(
helpTab
=
strings
.
Repeat
(
" "
,
helpTabWidth
)
// version is overwritten by ci/build.sh.
version
string
)
func
main
() {
cli
.
RunRoot
(
&
rootCmd
{})
}
var
_
interface
{
cli.
Command
cli.
FlaggedCommand
}
=
new
(
rootCmd
)
type
rootCmd
struct
{
skipSync
bool
syncBack
bool
printVersion
bool
noReuseConnection
bool
bindAddr
string
sshFlags
string
uploadCodeServer
string
}
func
(
c
*
rootCmd
)
Spec
() cli.
CommandSpec
{
return
cli.
CommandSpec
{
Name
:
"sshcode"
,
Usage
:
c
.
usage
(),
Desc
:
c
.
description
(),
}
}
func
(
c
*
rootCmd
)
RegisterFlags
(
fl
*
pflag.
FlagSet
) {
fl
.
BoolVar
(
&
c
.
skipSync
,
"skipsync"
,
false
,
"skip syncing local settings and extensions to remote host"
)
fl
.
BoolVar
(
&
c
.
syncBack
,
"b"
,
false
,
"sync extensions back on termination"
)
fl
.
BoolVar
(
&
c
.
printVersion
,
"version"
,
false
,
"print version information and exit"
)
fl
.
BoolVar
(
&
c
.
noReuseConnection
,
"no-reuse-connection"
,
false
,
"do not reuse SSH connection via control socket"
)
fl
.
StringVar
(
&
c
.
bindAddr
,
"bind"
,
""
,
"local bind address for SSH tunnel, in [HOST][:PORT] syntax (default: 127.0.0.1)"
)
fl
.
StringVar
(
&
c
.
sshFlags
,
"ssh-flags"
,
""
,
"custom SSH flags"
)
fl
.
StringVar
(
&
c
.
uploadCodeServer
,
"upload-code-server"
,
""
,
"custom code-server binary to upload to the remote host"
)
}
func
(
c
*
rootCmd
)
Run
(
fl
*
pflag.
FlagSet
) {
if
c
.
printVersion
{
fmt
.
Printf
(
"%v
\n
"
,
version
)
os
.
Exit
(
0
)
}
host
:=
fl
.
Arg
(
0
)
if
host
==
""
{
// If no host is specified output the usage.
fl
.
Usage
()
os
.
Exit
(
1
)
}
dir
:=
fl
.
Arg
(
1
)
if
dir
==
""
{
dir
=
"~"
}
err
:=
sshCode
(
host
,
dir
,
options
{
skipSync
:
c
.
skipSync
,
sshFlags
:
c
.
sshFlags
,
bindAddr
:
c
.
bindAddr
,
syncBack
:
c
.
syncBack
,
reuseConnection
:
!
c
.
noReuseConnection
,
uploadCodeServer
:
c
.
uploadCodeServer
,
})
if
err
!=
nil
{
flog
.
Fatal
(
"error: %v"
,
err
)
}
}
func
(
c
*
rootCmd
)
usage
()
string
{
return
"[FLAGS] HOST [DIR]"
}
func
(
c
*
rootCmd
)
description
()
string
{
return
fmt
.
Sprintf
(
`Start VS Code via code-server over SSH.
Environment variables:
%v%v use special VS Code settings dir.
%v%v use special VS Code extensions dir.
More info: https://github.com/cdr/sshcode
Arguments:
%vHOST is passed into the ssh command. Valid formats are '<ip-address>' or 'gcp:<instance-name>'.
%vDIR is optional.`
,
helpTab
,
vsCodeConfigDirEnv
,
helpTab
,
vsCodeExtensionsDirEnv
,
helpTab
,
helpTab
,
)
}
Back
|
FazBrowse Home
|
New Git URL