Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Jenkins 中文社区
jenkins-cli
提交
f5a3ff88
J
jenkins-cli
项目概览
Jenkins 中文社区
/
jenkins-cli
通知
49
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins-cli
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f5a3ff88
编写于
4月 24, 2020
作者:
LinuxSuRen
提交者:
GitHub
4月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Commnd documentation improments (#392)
上级
1f3587db
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
25 deletion
+46
-25
Makefile
Makefile
+3
-1
app/cmd/casc_open.go
app/cmd/casc_open.go
+1
-1
app/cmd/completion.go
app/cmd/completion.go
+32
-16
app/cmd/open.go
app/cmd/open.go
+9
-6
app/cmd/plugin_open.go
app/cmd/plugin_open.go
+1
-1
未找到文件。
Makefile
浏览文件 @
f5a3ff88
...
...
@@ -5,7 +5,9 @@ BUILD_TARGET = build
COMMIT
:=
$(
shell
git rev-parse
--short
HEAD
)
# CHANGE_LOG := $(shell echo -n "$(shell hub release show $(shell hub release --include-drafts -L 1))" | base64)
VERSION
:=
dev-
$(
shell
git describe
--tags
$(
shell
git rev-list
--tags
--max-count
=
1
))
BUILDFLAGS
=
-ldflags
"-X github.com/jenkins-zh/jenkins-cli/app.version=
$(VERSION)
-X github.com/jenkins-zh/jenkins-cli/app.commit=
$(COMMIT)
"
BUILDFLAGS
=
-ldflags
"-X github.com/jenkins-zh/jenkins-cli/app.version=
$(VERSION)
\
-X github.com/jenkins-zh/jenkins-cli/app.commit=
$(COMMIT)
\
-X github.com/jenkins-zh/jenkins-cli/app.date=
$(
shell
date +'%Y-%m-%d'
)
"
COVERED_MAIN_SRC_FILE
=
./main
PATH
:=
$(PATH)
:
$(PWD)
/bin
...
...
app/cmd/casc_open.go
浏览文件 @
f5a3ff88
...
...
@@ -32,7 +32,7 @@ var cascOpenCmd = &cobra.Command{
Long
:
i18n
.
T
(
"Open Configuration as Code page in browser"
),
PreRun
:
func
(
_
*
cobra
.
Command
,
_
[]
string
)
{
if
cascOpenOption
.
Browser
==
""
{
cascOpenOption
.
Browser
=
os
.
Getenv
(
"BROWSER"
)
cascOpenOption
.
Browser
=
os
.
Getenv
(
"
JCLI_
BROWSER"
)
}
},
RunE
:
func
(
_
*
cobra
.
Command
,
_
[]
string
)
(
err
error
)
{
...
...
app/cmd/completion.go
浏览文件 @
f5a3ff88
...
...
@@ -20,27 +20,43 @@ var completionOptions CompletionOptions
func
init
()
{
rootCmd
.
AddCommand
(
completionCmd
)
completionCmd
.
Flags
()
.
StringVarP
(
&
completionOptions
.
Type
,
"type"
,
""
,
"bash"
,
flags
:=
completionCmd
.
Flags
()
flags
.
StringVarP
(
&
completionOptions
.
Type
,
"type"
,
""
,
"bash"
,
i18n
.
T
(
fmt
.
Sprintf
(
"Generate different types of shell which are %v"
,
ShellTypes
)))
err
:=
completionCmd
.
RegisterFlagCompletionFunc
(
"type"
,
func
(
cmd
*
cobra
.
Command
,
args
[]
string
,
toComplete
string
)
(
i
[]
string
,
directive
cobra
.
ShellCompDirective
)
{
return
ShellTypes
,
cobra
.
ShellCompDirectiveDefault
})
if
err
!=
nil
{
completionCmd
.
PrintErrf
(
"register flag type for sub-command doc failed %#v
\n
"
,
err
)
}
}
var
completionCmd
=
&
cobra
.
Command
{
Use
:
"completion"
,
Short
:
i18n
.
T
(
"Generate bash completion scripts"
),
Long
:
i18n
.
T
(
"Generate bash completion scripts"
),
Example
:
`# Installing bash completion on macOS using homebrew
## If running Bash 3.2 included with macOS
brew install bash-completion
## or, if running Bash 4.1+
brew install bash-completion@2
## you may need add the completion to your completion directory
jcli completion > $(brew --prefix)/etc/bash_completion.d/jcli
## If you get trouble, please visit https://github.com/jenkins-zh/jenkins-cli/issues/83.
# Load the jcli completion code for zsh[1] into the current shell
source <(jcli completion --type zsh)
# Set the jcli completion code for zsh[1] to autoload on startup
jcli completion --type zsh > "${fpath[1]}/_jcli"`
,
Short
:
i18n
.
T
(
"Generate shell completion scripts"
),
Long
:
i18n
.
T
(
`Generate shell completion scripts
Normally you don't need to do more extra work to have this feature if you've installed jcli by brew`
),
Example
:
`Installing bash completion on macOS using homebrew
If running Bash 3.2 included with macOS
brew install bash-completion
or, if running Bash 4.1+
brew install bash-completion@2
You may need to add the completion to your completion directory by the following command
jcli completion > $(brew --prefix)/etc/bash_completion.d/jcli
If you get trouble, please visit https://github.com/jenkins-zh/jenkins-cli/issues/83.
In order to have good experience on zsh completion, ohmyzsh is a good choice.
Please install ohmyzsh by the following command
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Get more details about onmyzsh from https://github.com/ohmyzsh/ohmyzsh
Load the jcli completion code for zsh[1] into the current shell
source <(jcli completion --type zsh)
Set the jcli completion code for zsh[1] to autoload on startup
jcli completion --type zsh > "${fpath[1]}/_jcli"`
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
_
[]
string
)
(
err
error
)
{
shellType
:=
completionOptions
.
Type
switch
shellType
{
...
...
app/cmd/open.go
浏览文件 @
f5a3ff88
...
...
@@ -42,13 +42,17 @@ func init() {
}
var
openCmd
=
&
cobra
.
Command
{
Use
:
"open"
,
Short
:
i18n
.
T
(
"Open your Jenkins with a browser"
),
Long
:
i18n
.
T
(
`Open your Jenkins with a browser`
),
Example
:
`jcli open -n [config name]`
,
Use
:
"open"
,
Short
:
i18n
.
T
(
"Open your Jenkins with a browser"
),
Long
:
i18n
.
T
(
`Open your Jenkins with a browser`
),
Example
:
`jcli open -n [config name]
Open Jenkins with a specific browser is useful in some use cases. For example, one browser has a proxy setting.
There are two ways to achieve this:
jcli open --browser "Google-Chrome"
JCLI_BROWSER="Google Chrome" jcli open`
,
PreRun
:
func
(
_
*
cobra
.
Command
,
_
[]
string
)
{
if
openOption
.
Browser
==
""
{
openOption
.
Browser
=
os
.
Getenv
(
"BROWSER"
)
openOption
.
Browser
=
os
.
Getenv
(
"
JCLI_
BROWSER"
)
}
},
RunE
:
openOption
.
run
,
...
...
@@ -99,7 +103,6 @@ func (o *OpenOption) run(_ *cobra.Command, args []string) (err error) {
// parseName the string expect likes name or name.external
func
(
o
*
OpenOption
)
parseName
(
configName
string
)
(
jenkins
,
external
string
)
{
array
:=
strings
.
SplitN
(
configName
,
"."
,
2
)
fmt
.
Println
(
array
)
if
len
(
array
)
>
0
{
jenkins
=
array
[
0
]
}
...
...
app/cmd/plugin_open.go
浏览文件 @
f5a3ff88
...
...
@@ -30,7 +30,7 @@ var pluginOpenCmd = &cobra.Command{
Long
:
`Open update center server in browser`
,
PreRun
:
func
(
_
*
cobra
.
Command
,
_
[]
string
)
{
if
pluginOpenOption
.
Browser
==
""
{
pluginOpenOption
.
Browser
=
os
.
Getenv
(
"BROWSER"
)
pluginOpenOption
.
Browser
=
os
.
Getenv
(
"
JCLI_
BROWSER"
)
}
},
RunE
:
func
(
_
*
cobra
.
Command
,
_
[]
string
)
(
err
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录