[PR #9040] [CLOSED] Refactor CLI structure: split commands and utilities into separate files #23378

Closed
opened 2026-04-19 16:57:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9040
Author: @pixel365
Created: 2/12/2025
Status: Closed

Base: mainHead: cmd


📝 Commits (1)

  • fc9e0f0 Refactor CLI structure: split commands and utilities into separate files

📊 Changes

17 files changed (+1488 additions, -1269 deletions)

View changed files

📝 cmd/cmd.go (+29 -1262)
📝 cmd/cmd_test.go (+6 -6)
cmd/copy.go (+34 -0)
cmd/create.go (+196 -0)
cmd/delete.go (+48 -0)
cmd/helpers.go (+225 -0)
📝 cmd/interactive.go (+88 -1)
cmd/list.go (+56 -0)
cmd/ollama.go (+53 -0)
cmd/ps.go (+79 -0)
cmd/pull.go (+78 -0)
cmd/push.go (+98 -0)
cmd/run.go (+239 -0)
cmd/runner.go (+27 -0)
cmd/serve.go (+94 -0)
cmd/show.go (+104 -0)
cmd/stop.go (+34 -0)

📄 Description

Refactor CLI Command Structure

This pull request refactors the structure of the project's CLI by splitting commands and utilities into separate files.

Changes:

  • Commands: Each individual command now resides in its own file, making it easier to manage and extend the CLI functionality.
  • Utilities: Common functions and helper utilities are moved to a separate package to be reused across different commands.
  • Main CLI File: The main file is now significantly smaller, improving readability and maintainability.
  • Adding New Commands: The process of adding new commands is now streamlined, requiring only the creation of a new file for the command logic, which is then plugged into the main CLI structure.

Benefits:

  • Improved Maintainability: With the CLI commands isolated, it’s easier to maintain and extend the functionality of the project.
  • Better Readability: The code is now better organized, making it easier to navigate and understand.
  • Simplified Development: New contributors or developers working on new features can quickly add commands without touching the core structure.

This refactor is aimed at improving the project's scalability, making future updates more efficient.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/9040 **Author:** [@pixel365](https://github.com/pixel365) **Created:** 2/12/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `cmd` --- ### 📝 Commits (1) - [`fc9e0f0`](https://github.com/ollama/ollama/commit/fc9e0f02f0b222e4a22b13baa13f5dc9ca4dc4ba) Refactor CLI structure: split commands and utilities into separate files ### 📊 Changes **17 files changed** (+1488 additions, -1269 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+29 -1262) 📝 `cmd/cmd_test.go` (+6 -6) ➕ `cmd/copy.go` (+34 -0) ➕ `cmd/create.go` (+196 -0) ➕ `cmd/delete.go` (+48 -0) ➕ `cmd/helpers.go` (+225 -0) 📝 `cmd/interactive.go` (+88 -1) ➕ `cmd/list.go` (+56 -0) ➕ `cmd/ollama.go` (+53 -0) ➕ `cmd/ps.go` (+79 -0) ➕ `cmd/pull.go` (+78 -0) ➕ `cmd/push.go` (+98 -0) ➕ `cmd/run.go` (+239 -0) ➕ `cmd/runner.go` (+27 -0) ➕ `cmd/serve.go` (+94 -0) ➕ `cmd/show.go` (+104 -0) ➕ `cmd/stop.go` (+34 -0) </details> ### 📄 Description ### Refactor CLI Command Structure This pull request refactors the structure of the project's CLI by splitting commands and utilities into separate files. #### Changes: - **Commands:** Each individual command now resides in its own file, making it easier to manage and extend the CLI functionality. - **Utilities:** Common functions and helper utilities are moved to a separate package to be reused across different commands. - **Main CLI File:** The main file is now significantly smaller, improving readability and maintainability. - **Adding New Commands:** The process of adding new commands is now streamlined, requiring only the creation of a new file for the command logic, which is then plugged into the main CLI structure. #### Benefits: - **Improved Maintainability:** With the CLI commands isolated, it’s easier to maintain and extend the functionality of the project. - **Better Readability:** The code is now better organized, making it easier to navigate and understand. - **Simplified Development:** New contributors or developers working on new features can quickly add commands without touching the core structure. This refactor is aimed at improving the project's scalability, making future updates more efficient. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 16:57:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#23378