Skip to content

Commit 6ee7164

Browse files
authored
Support install binary to specific directory (#285)
1 parent 7a32e72 commit 6ee7164

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ inputs:
44
version:
55
description: 'The version of hd'
66
required: false
7-
default: 'v0.0.68'
7+
default: 'v0.0.69'
88
tool:
99
description: 'The desired tool name'
1010
required: true
1111
runs:
1212
using: 'docker'
13-
image: 'docker://ghcr.io/linuxsuren/hd:v0.0.68'
13+
image: 'docker://ghcr.io/linuxsuren/hd:v0.0.69'
1414
args:
1515
- hd
16-
- get
16+
- install
1717
- ${{ inputs.tool }}
1818
- --fetch=true
19-
- --output=/github/home/${{ inputs.tool }}
19+
- --target=/github/home/

cmd/install.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Cannot find your desired package? Please run command: hd fetch --reset, then try
4949
"Indicate if install it via go install github.com/xxx/xxx")
5050
flags.StringVarP(&opt.fromBranch, "from-branch", "", "master",
5151
"Only works if the flag --from-source is true")
52+
flags.StringVarP(&opt.target, "target", "", "/usr/local/bin", "The target installation directory")
5253
flags.BoolVarP(&opt.goget, "goget", "", viper.GetBool("fetch"),
5354
"Use command goget to download the binary, only works if the flag --from-source is true")
5455

@@ -76,6 +77,7 @@ type installOption struct {
7677
CleanPackage bool
7778
fromSource bool
7879
fromBranch string
80+
target string
7981
goget bool
8082
force bool
8183

@@ -159,6 +161,9 @@ func (o *installOption) install(cmd *cobra.Command, args []string) (err error) {
159161
}
160162
}
161163

164+
if o.target != "" {
165+
o.Package.TargetDirectory = o.target
166+
}
162167
if o.Package.TargetDirectory == "" {
163168
o.Package.TargetDirectory = "/usr/local/bin"
164169
}

0 commit comments

Comments
 (0)