Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
devtool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
k8s
devtool
Commits
bc03d2f2
Commit
bc03d2f2
authored
Apr 15, 2019
by
Christopher Harm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding bash completion
Fixes
#5
parent
7f193d46
Pipeline
#31136
passed with stages
in 41 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
13 deletions
+73
-13
cmd/ci.go
cmd/ci.go
+3
-3
cmd/completion.go
cmd/completion.go
+56
-0
cmd/config.go
cmd/config.go
+3
-3
cmd/root.go
cmd/root.go
+11
-6
devtool.go
devtool.go
+0
-1
No files found.
cmd/ci.go
View file @
bc03d2f2
...
...
@@ -30,9 +30,9 @@ var environmentSuffix string
var
ciCmd
=
&
cobra
.
Command
{
Use
:
"ci"
,
Short
:
"Build tools for the CI system"
,
//
Run: func(cmd *cobra.Command, args []string) {
// fmt.Println("config called"
)
//
},
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmd
.
HelpFunc
()(
cmd
,
args
)
},
}
func
init
()
{
...
...
cmd/completion.go
0 → 100644
View file @
bc03d2f2
// Copyright © 2019 NAME HERE <EMAIL ADDRESS>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
cmd
import
(
"os"
"github.com/spf13/cobra"
)
// completionCmd represents the completion command
var
completionCmd
=
&
cobra
.
Command
{
Use
:
"completion"
,
Short
:
"Generates bash completion scripts"
,
Long
:
`To load completion run
source <(devtool completion)
To configure your bash shell to load completions for each session add to your bashrc
# ~/.bashrc or ~/.profile
source <(devtool completion)
`
,
PersistentPreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
// Do Nothing
},
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rootCmd
.
GenBashCompletion
(
os
.
Stdout
)
},
}
func
init
()
{
rootCmd
.
AddCommand
(
completionCmd
)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// completionCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// completionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
cmd/config.go
View file @
bc03d2f2
...
...
@@ -22,9 +22,9 @@ import (
var
configCmd
=
&
cobra
.
Command
{
Use
:
"config"
,
Short
:
"Manage the projects build configuration"
,
//
Run: func(cmd *cobra.Command, args []string) {
// fmt.Println("config called"
)
//
},
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmd
.
HelpFunc
()(
cmd
,
args
)
},
}
func
init
()
{
...
...
cmd/root.go
View file @
bc03d2f2
...
...
@@ -38,7 +38,12 @@ var rootCmd = &cobra.Command{
Long
:
`A tool used by software engineering to build applications.`
,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmd
.
HelpFunc
()(
cmd
,
args
)
},
PersistentPreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
PrintLogo
()
},
}
// Execute adds all child commands to the root command and sets flags appropriately.
...
...
@@ -86,11 +91,11 @@ func initConfig() {
viper
.
SetEnvKeyReplacer
(
replacer
)
// If a config file is found, read it in.
if
err
:=
viper
.
ReadInConfig
();
err
==
nil
{
fmt
.
Println
(
"Using config file:"
,
viper
.
ConfigFileUsed
())
}
else
{
color
.
Red
(
err
.
Error
())
}
//
if err := viper.ReadInConfig(); err == nil {
//
fmt.Println("Using config file:", viper.ConfigFileUsed())
//
} else {
//
color.Red(err.Error())
//
}
}
func
PrintLogo
()
{
...
...
devtool.go
View file @
bc03d2f2
...
...
@@ -3,6 +3,5 @@ package main
import
"git.psu.edu/k8s/devtool/cmd"
func
main
()
{
cmd
.
PrintLogo
()
cmd
.
Execute
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment