-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Use PHP Mirror to download and install on x64 arch
- Loading branch information
1 parent
128da80
commit 4555bc5
Showing
6 changed files
with
165 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ch | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/BrainBuzzer/php-ch/pkg" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var listCommand = &cobra.Command{ | ||
Use: "list", | ||
Short: "List all available PHP versions", | ||
Long: `List all available PHP versions`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
root := os.Getenv("PHP_HOME") | ||
vs, err := pkg.ListAllVersions() | ||
if err != nil { | ||
fmt.Println("Error while fetching versions: ", err) | ||
} | ||
|
||
for _, v := range vs { | ||
installdir := filepath.Join(root, "versions", v.String()) | ||
if _, err := os.Stat(installdir); os.IsNotExist(err) { | ||
fmt.Println(v.String()) | ||
} else { | ||
fmt.Println(v.String() + "* Installed") | ||
} | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(listCommand) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ch | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var versionCommand = &cobra.Command{ | ||
Use: "set", | ||
Short: "Set PHP Version", | ||
Aliases: []string{"v"}, | ||
Long: `This command checks if there is existing PHP installation for given version, if not, downloads the specified PHP version.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("0.0.3") | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(versionCommand) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters