Add changeport command
Build Release Binaries / Build linux-arm64 (push) Successful in 14s
Build Release Binaries / Build linux-amd64 (push) Successful in 15s

This commit is contained in:
2026-08-24 13:43:17 +02:00
parent 9546159ff1
commit 445dd8638b
4 changed files with 69 additions and 3 deletions
+15
View File
@@ -0,0 +1,15 @@
package command
func (i *Command) RunChangePort() error {
return i.runSteps(
i.CryosparcmChangePortStep(
i.cfg.HostName,
i.cfg.CryosparcPath,
i.cfg.BasePort,
portStart,
portEnd,
portCount,
i.cfg.CryosparcmHelp,
),
)
}
+2 -2
View File
@@ -10,8 +10,8 @@ import (
)
var (
portStart uint = 39400 // Start port range to assign new base port
portEnd uint = 40000 // End port range to assign new base port
portStart uint = 61000 // Start port range to assign new base port
portEnd uint = 62000 // End port range to assign new base port
portCount uint = 10 // Number of contiguous ports available
)
+27 -1
View File
@@ -76,7 +76,6 @@ func (i *Command) CryosparcmCreateUserStep(
Message: fmt.Sprintf("Creating CryoSPARC user (instance: %s)", cryosparcpath),
CompletedMessage: nil,
Condition: func() (bool, error) {
return true, nil
},
Prompt: func() *huh.Form {
@@ -163,6 +162,33 @@ func (i *Command) CryosparcmCreateUserStep(
}
}
func (i *Command) CryosparcmChangePortStep(
hostname,
cryosparcpath string,
port, start, end, count uint,
help bool) ui.Step {
return ui.Step{
Message: fmt.Sprintf("Changing base port (instance: %s)", cryosparcpath),
CompletedMessage: nil,
Exec: func() *exec.Cmd {
if port == 0 {
i.setCryosparcBasePort(hostname, start, end, count)
}
return cryosparcmCmd(
hostname,
cryosparcpath,
"",
help,
"changeport",
strconv.FormatUint(uint64(i.cfg.BasePort), 10),
)
},
}
}
// =============================================================================
// cryosparcm commands Steps
// =============================================================================
+25
View File
@@ -93,6 +93,13 @@ func main() {
cryosparcwCmd.PreRunE = preRunCmd("worker", false)
// changeport commands
changeportCmd := newCommand(
"changeport",
"Change base port",
runCmd((*command.Command).RunChangePort),
)
// Install commands
installCmd := newCommand(
"install",
@@ -197,6 +204,7 @@ func main() {
instancesCmd,
cryosparcmCmd,
cryosparcwCmd,
changeportCmd,
installCmd,
lanesCmd,
userCmd,
@@ -217,6 +225,11 @@ func main() {
// =============================================
addCryosparcwFlags(cryosparcwCmd)
// =============================================
// changeport CLI Flags
// =============================================
addChangePortFlags(changeportCmd)
// =============================================
// Install CLI Flags
// =============================================
@@ -663,6 +676,18 @@ func addCryosparcmFlags(cmd *cobra.Command) {
flags.SortFlags = false
}
// changeport
func addChangePortFlags(cmd *cobra.Command) {
flags := cmd.Flags()
addCryosparcPathFlag(cmd)
addHostnameFlag(cmd)
addBasePortFlag(cmd)
flags.SetInterspersed(false)
flags.SortFlags = false
}
// cryosparcw
func addCryosparcwFlags(cmd *cobra.Command) {
flags := cmd.Flags()