Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
boilr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
boilr
Commits
cb09cecb
Commit
cb09cecb
authored
9 years ago
by
Tamer Tas
Browse files
Options
Downloads
Patches
Plain Diff
Update shell completion configuration to remove root privileges prompt
parent
bd036e68
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
install
+10
-8
10 additions, 8 deletions
install
pkg/boilr/configuration.go
+2
-0
2 additions, 0 deletions
pkg/boilr/configuration.go
pkg/cmd/bash_completion.go
+25
-9
25 additions, 9 deletions
pkg/cmd/bash_completion.go
with
37 additions
and
17 deletions
install
+
10
−
8
View file @
cb09cecb
...
@@ -31,20 +31,20 @@ symlink() {
...
@@ -31,20 +31,20 @@ symlink() {
}
}
configure
()
{
configure
()
{
# Auto-completion
$HOME
/bin/boilr init
if
[
$?
-ne
0
]
;
then
binary_error
=
"Failed to complete boilr initialization"
return
fi
# Auto-completion prompt
if
[
-z
"
$auto_completion
"
]
;
then
if
[
-z
"
$auto_completion
"
]
;
then
ask
"Do you want to enable auto-completion for boilr commmands?"
ask
"Do you want to enable auto-completion for boilr commmands?"
auto_completion
=
$?
auto_completion
=
$?
fi
fi
if
[
$auto_completion
-eq
1
]
;
then
if
[
$auto_completion
-eq
1
]
;
then
sudo
$HOME
/bin/boilr configure-bash-completion
$HOME
/bin/boilr configure-bash-completion
fi
$HOME
/bin/boilr init
if
[
$?
-ne
0
]
;
then
binary_error
=
"Failed to complete boilr initialization"
return
fi
fi
}
}
...
@@ -124,5 +124,7 @@ esac
...
@@ -124,5 +124,7 @@ esac
cat
<<
EOF
cat
<<
EOF
Completed installation
Completed installation
Boilr executable is installed to ~/bin/boilr
For more information, see: https://github.com/tmrts/boilr
For more information, see: https://github.com/tmrts/boilr
EOF
EOF
This diff is collapsed.
Click to expand it.
pkg/boilr/configuration.go
+
2
−
0
View file @
cb09cecb
...
@@ -48,6 +48,7 @@ const (
...
@@ -48,6 +48,7 @@ const (
// file in the configuration directory.
// file in the configuration directory.
var
Configuration
=
struct
{
var
Configuration
=
struct
{
FilePath
string
FilePath
string
ConfigDirPath
string
TemplateDirPath
string
TemplateDirPath
string
}{}
}{}
...
@@ -68,6 +69,7 @@ func init() {
...
@@ -68,6 +69,7 @@ func init() {
}
}
Configuration
.
FilePath
=
filepath
.
Join
(
homeDir
,
ConfigDirPath
,
ConfigFileName
)
Configuration
.
FilePath
=
filepath
.
Join
(
homeDir
,
ConfigDirPath
,
ConfigFileName
)
Configuration
.
ConfigDirPath
=
filepath
.
Join
(
homeDir
,
ConfigDirPath
)
Configuration
.
TemplateDirPath
=
filepath
.
Join
(
homeDir
,
ConfigDirPath
,
TemplateDir
)
Configuration
.
TemplateDirPath
=
filepath
.
Join
(
homeDir
,
ConfigDirPath
,
TemplateDir
)
// Read .config/boilr/config.json if exists
// Read .config/boilr/config.json if exists
...
...
This diff is collapsed.
Click to expand it.
pkg/cmd/bash_completion.go
+
25
−
9
View file @
cb09cecb
package
cmd
package
cmd
import
(
import
(
"errors"
"fmt"
"fmt"
"os"
"os"
"path/filepath"
"path/filepath"
"strings"
cli
"github.com/spf13/cobra"
cli
"github.com/spf13/cobra"
"github.com/tmrts/boilr/pkg/boilr"
"github.com/tmrts/boilr/pkg/boilr"
"github.com/tmrts/boilr/pkg/util/exit"
"github.com/tmrts/boilr/pkg/util/exit"
)
)
const
bashrcText
=
`
# Enables shell command completion for boilr
source $HOME/bin/boilr
`
func
configureBashCompletion
()
error
{
func
configureBashCompletion
()
error
{
var
bash_completion_dir
string
bash_completion_file
:=
filepath
.
Join
(
boilr
.
Configuration
.
ConfigDirPath
,
"completion.bash"
)
if
bash_completion_dir
=
os
.
Getenv
(
"BASH_COMPLETION_COMPAT_DIR"
);
bash_completion_dir
==
""
{
bash_completion_dir
=
"/etc/bash_completion.d"
}
bash_completion_file
:=
filepath
.
Join
(
bash_completion_dir
,
boilr
.
AppName
+
".bash"
)
if
err
:=
Root
.
GenBashCompletionFile
(
bash_completion_file
);
err
!=
nil
{
return
err
}
if
err
:=
Root
.
GenBashCompletionFile
(
bash_completion_file
);
err
!=
nil
{
if
err
:=
Root
.
GenBashCompletionFile
(
bash_completion_file
);
err
!=
nil
{
if
strings
.
Contains
(
err
.
Error
(),
"permission"
)
{
return
err
return
fmt
.
Errorf
(
"couldn't configure bash completion for %s: permission denied"
,
boilr
.
AppName
)
}
}
bashrcPath
:=
filepath
.
Join
(
os
.
Getenv
(
"HOME"
),
".bashrc"
)
if
bashrcPath
==
""
{
return
errors
.
New
(
"environment variable ${HOME} should be set"
)
}
f
,
err
:=
os
.
OpenFile
(
bashrcPath
,
os
.
O_APPEND
|
os
.
O_WRONLY
,
0600
)
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
if
_
,
err
=
f
.
WriteString
(
bashrcText
);
err
!=
nil
{
return
err
return
err
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment