Skip to content

Commit

Permalink
✨ feat: improve repo organization & separate cli and gui (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquidwe authored Dec 16, 2024
1 parent 4b37715 commit 5690254
Show file tree
Hide file tree
Showing 27 changed files with 9 additions and 30 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 6 additions & 14 deletions commands/commander.go → cli/commands/commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package commands

import (
"fmt"
"log"
"manuscript-core/pkg"
"os"

Expand Down Expand Up @@ -49,7 +48,7 @@ You'll be prompted to select:
}

var jobListCmd = &cobra.Command{
Use: "list [directory]",
Use: "list",
Aliases: []string{"ls"},
Short: "List all manuscript jobs",
Long: `📋 View all running manuscript jobs
Expand All @@ -71,20 +70,13 @@ Usage:
- Specify a directory path to check manuscripts in that location`,
Example: `>> manuscript-cli ls
>> manuscript-cli list /path/to/manuscripts`,
Args: cobra.MaximumNArgs(1),
Args: cobra.MaximumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
var dir string
// if no args, use default manuscript directory
if len(args) == 0 {
config, err := pkg.LoadConfig(manuscriptConfig)
if err != nil {
log.Fatalf("Error: Failed to load config: %v", err)
}
dir = fmt.Sprintf("%s/%s", config.BaseDir, manuscriptBaseName)
} else {
dir = args[0] // use specified directory if user input
config, err := pkg.LoadConfig(manuscriptConfig)
if err != nil {
fmt.Println("Error: Failed to load manuscript config: %v", err)
}
ListJobs(dir)
ListJobs(config)
},
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
manuscriptBaseName = "manuscript"
manuscriptBaseName = "manuscripts"
manuscriptBaseDir = "$HOME"
manuscriptConfig = "$HOME/.manuscript_config.ini"
networkChainURL = "https://api.chainbase.com"
Expand Down
File renamed without changes.
17 changes: 2 additions & 15 deletions commands/jobs_manuscript.go → cli/commands/jobs_manuscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func formatDurationToMinutes(durationMs int64) string {
return fmt.Sprintf("%d minutes", durationMinutes)
}

func ListJobs(dir string) {
func ListJobs(config *pkg.Config) {
_ = pkg.ExecuteStepWithLoading("Checking jobs", false, func() error {
// Step 1: Check for running Docker containers
dockers, err := getRunningContainers()
Expand All @@ -54,21 +54,8 @@ func ListJobs(dir string) {
fmt.Println("\r📍 There are no jobs running...")
}

// Step 2: Get manuscripts based on source (config or directory)
manuscripts, err := getManuscripts(dir)
if err != nil {
return fmt.Errorf("failed to get manuscripts: %w", err)
}

if len(manuscripts) == 0 {
if dir != "" {
fmt.Printf("\r⚠️ No manuscript files found in %s\n", dir)
}
return nil
}

// Step 3: Check and display state for each manuscript
displayManuscriptStates(manuscripts, dockers)
displayManuscriptStates(config.Manuscripts, dockers)
return nil
})
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5690254

Please sign in to comment.