@@ -18,16 +18,21 @@ import (
1818
1919func MakeOciInstall () * cobra.Command {
2020 command := & cobra.Command {
21- Use : "install" ,
21+ Use : "install IMAGE [PATH] " ,
2222 Aliases : []string {"i" },
2323 Short : "Install the contents of an OCI image to a given path" ,
2424 Long : `Use this command to install binaries or packages distributed within an
2525OCI image.` ,
26- Example : ` # Install slicer to /usr/local/bin
26+ Example : ` # Install slicer to /usr/local/bin (default)
27+ # Files will be extracted to /usr/local/bin/slicer
2728 arkade oci install ghcr.io/openfaasltd/slicer
2829
29- # Install a specific version of slicer to /tmp/
30- arkade oci install ghcr.io/openfaasltd/slicer --path /tmp --version 0.1.0
30+ # Install to current directory
31+ arkade oci install ghcr.io/openfaasltd/slicer .
32+
33+ # Install to a custom path like /tmp/
34+ # Files will be extracted to /tmp/slicer
35+ arkade oci install ghcr.io/openfaasltd/slicer /tmp --version 0.1.0
3136
3237 # Install slicer for arm64 as an architecture override, instead of using uname
3338 arkade oci install ghcr.io/openfaasltd/slicer --arch arm64
@@ -39,20 +44,22 @@ OCI image.`,
3944 }
4045
4146 command .Flags ().StringP ("version" , "v" , "latest" , "The version or leave blank to determine the latest available version" )
42- command .Flags ().String ("path" , "/usr/local/bin" , "Installation path, where a buildkitd subfolder will be created " )
47+ command .Flags ().String ("path" , "/usr/local/bin" , "(deprecated: use positional argument) Installation path " )
4348 command .Flags ().Bool ("progress" , true , "Show download progress" )
4449 command .Flags ().String ("arch" , "" , "CPU architecture i.e. amd64" )
4550 command .Flags ().String ("os" , "" , "OS i.e. linux" )
4651
4752 command .Flags ().BoolP ("gzipped" , "g" , false , "Is this a gzipped tarball?" )
4853 command .Flags ().Bool ("quiet" , false , "Suppress progress output" )
4954
55+ // Hide the deprecated --path flag
56+ command .Flags ().MarkHidden ("path" )
57+
5058 command .PreRunE = func (cmd * cobra.Command , args []string ) error {
5159 return nil
5260 }
5361
5462 command .RunE = func (cmd * cobra.Command , args []string ) error {
55- installPath , _ := cmd .Flags ().GetString ("path" )
5663 version , _ := cmd .Flags ().GetString ("version" )
5764 gzipped , _ := cmd .Flags ().GetBool ("gzipped" )
5865 quiet , _ := cmd .Flags ().GetBool ("quiet" )
@@ -63,6 +70,15 @@ OCI image.`,
6370
6471 imageName := args [0 ]
6572
73+ // Determine installation path
74+ // Priority: arg[1] > --path flag > default
75+ installPath := "/usr/local/bin"
76+ if len (args ) >= 2 {
77+ installPath = args [1 ]
78+ } else if cmd .Flags ().Changed ("path" ) {
79+ installPath , _ = cmd .Flags ().GetString ("path" )
80+ }
81+
6682 switch imageName {
6783 case "vmmeter" :
6884 imageName = "ghcr.io/openfaasltd/vmmeter"
0 commit comments