cmd

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cmd implements each user-facing subcommand plus the interactive main menu. Each file is a thin orchestration layer over internal/config, internal/fabric, and internal/ui — keep it that way: if a file reaches for complex logic, factor the logic into one of those packages and keep cmd as the wiring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(configPath string) error

Add prompts for a customer name, saves an empty customer, then drops straight into the edit sub-menu so the user can add environments without running a second command.

func AddWithAPI

func AddWithAPI(configPath string, client APIClient) error

func Edit

func Edit(configPath string) error

Edit is the top-level customer editing flow. Drills down into a per-customer sub-menu where the user can add / rename / drill into environments. Each environment in turn has its own sub-menu for managing its workspace list — see editEnvironmentLoop.

func EditWithAPI

func EditWithAPI(configPath string, client APIClient) error

func Favorites

func Favorites(configPath string) error

Favorites walks the user through pinning notebooks and their preferred parameters for the currently-selected customer. This is an interactive- only flow — every step is a prompt, nothing is mutated on disk until the user either drills into param-editing (incremental save) or picks "Save and exit".

Design note: favourites are per-customer, not per-environment. Notebook display names are stable across DEV/TEST/PROD in practice; their IDs are not. Storing names lets the same favourite apply to every env.

func FavoritesWithAPI

func FavoritesWithAPI(configPath string, client APIClient) error

FavoritesWithAPI is the flow with an injectable APIClient for tests.

func Help

func Help()

Help prints a concise usage summary. Kept as a static string rather than generated from flag metadata — the interactive flows don't have flags anyway, and a hand-written block reads better than auto-formatted help.

func List

func List(configPath string) error

func Logout

func Logout(configPath string) error

Logout clears OAuth tokens cached in the OS keychain for every known customer plus the "default" profile (used by cmd/fetch-nb when run without a customer context). Doesn't delete the config itself — just the credentials. Users log back in on their next run.

Keyring delete failures are aggregated and returned rather than swallowed: printing "cleared" when a long-lived refresh token actually survived would give false credential-hygiene assurance on a shared or handed-off machine.

func MainMenu(configPath string)

MainMenu is the interactive loop shown when futils is invoked with no arguments. Top-level entries are split into "Actions" (what you do *to* Fabric) and "Settings" (managing the tool's local state). Customer CRUD lives behind a "Manage customers" submenu so it doesn't crowd out the day-to-day actions in the top menu.

func Move

func Move(configPath string) error

Move is the top-level entry point for the `move` subcommand.

func MoveWithAPI

func MoveWithAPI(configPath string, client APIClient) error

MoveWithAPI is the testable entry point. Tests swap DefaultAPI for a fake before calling.

func Refresh

func Refresh(configPath string) error

Refresh is the top-level entry point for the `refresh` subcommand. Walks the user through customer → env → semantic model → tables → trigger, then polls until completion.

func RefreshWithAPI

func RefreshWithAPI(configPath string, client APIClient) error

func Remove

func Remove(configPath string) error

func Run

func Run(configPath string) error

Run is the top-level entry point for the `run` subcommand.

func RunWithAPI

func RunWithAPI(configPath string, client APIClient) error

RunWithAPI walks the full user flow: pick customer → env → notebook, fill out the parameter form, submit, and poll to completion. Tests drive this directly with a fake APIClient.

Types

type APIClient

type APIClient interface {
	GetAccessToken(profile string) (string, error)
	GetWorkspaceID(token, workspaceName string) (string, error)
	ListWorkspaces(token string) ([]fabric.Workspace, error)
	ListNotebooks(token, workspaceID string) ([]fabric.Item, error)
	GetNotebookIpynb(token, workspaceID, itemID string) ([]byte, error)
	RunNotebook(token, workspaceID, itemID string, inputs []fabric.JobInput, lakehouse *fabric.DefaultLakehouse) (string, error)
	GetJobInstance(token, instanceURL string) (fabric.JobInstanceStatus, error)

	// Move flow.
	ListItems(token, workspaceID string) ([]fabric.Item, error)
	ListItemsByType(token, workspaceID, itemType string) ([]fabric.Item, error)
	GetItemDefinition(token, workspaceID, itemID, format string) (*fabric.Definition, error)
	CreateItem(token, workspaceID, displayName, itemType string, def *fabric.Definition) (fabric.Item, error)
	UpdateItemDefinition(token, workspaceID, itemID string, def *fabric.Definition) error
	RebindReport(token, workspaceID, reportID, datasetID string) error

	// Refresh flow.
	ListDatasets(token, workspaceID string) ([]fabric.Dataset, error)
	QueryRefreshableTables(token, workspaceID, datasetID string) ([]string, error)
	TriggerRefresh(token, workspaceID, datasetID string, tables []string) (string, error)
	WaitForRefresh(token, workspaceID, datasetID, requestID string) (fabric.RefreshStatus, error)
}

APIClient abstracts the Fabric calls the run flow needs. Lets us swap in a fake for tests or demo mode without touching command logic.

var DefaultAPI APIClient = RealAPIClient{}

DefaultAPI is what Run() uses when called from the main menu. Test code can point it at a fake before invoking RunWithAPI.

type RealAPIClient

type RealAPIClient struct{}

RealAPIClient just forwards to the internal/fabric package functions.

func (RealAPIClient) CreateItem

func (RealAPIClient) CreateItem(token, workspaceID, displayName, itemType string, def *fabric.Definition) (fabric.Item, error)

func (RealAPIClient) GetAccessToken

func (RealAPIClient) GetAccessToken(profile string) (string, error)

func (RealAPIClient) GetItemDefinition

func (RealAPIClient) GetItemDefinition(token, workspaceID, itemID, format string) (*fabric.Definition, error)

func (RealAPIClient) GetJobInstance

func (RealAPIClient) GetJobInstance(token, instanceURL string) (fabric.JobInstanceStatus, error)

func (RealAPIClient) GetNotebookIpynb

func (RealAPIClient) GetNotebookIpynb(token, workspaceID, itemID string) ([]byte, error)

func (RealAPIClient) GetWorkspaceID

func (RealAPIClient) GetWorkspaceID(token, workspaceName string) (string, error)

func (RealAPIClient) ListDatasets

func (RealAPIClient) ListDatasets(token, workspaceID string) ([]fabric.Dataset, error)

func (RealAPIClient) ListItems

func (RealAPIClient) ListItems(token, workspaceID string) ([]fabric.Item, error)

func (RealAPIClient) ListItemsByType

func (RealAPIClient) ListItemsByType(token, workspaceID, itemType string) ([]fabric.Item, error)

func (RealAPIClient) ListNotebooks

func (RealAPIClient) ListNotebooks(token, workspaceID string) ([]fabric.Item, error)

func (RealAPIClient) ListWorkspaces

func (RealAPIClient) ListWorkspaces(token string) ([]fabric.Workspace, error)

func (RealAPIClient) QueryRefreshableTables

func (RealAPIClient) QueryRefreshableTables(token, workspaceID, datasetID string) ([]string, error)

func (RealAPIClient) RebindReport

func (RealAPIClient) RebindReport(token, workspaceID, reportID, datasetID string) error

func (RealAPIClient) RunNotebook

func (RealAPIClient) RunNotebook(token, workspaceID, itemID string, inputs []fabric.JobInput, lakehouse *fabric.DefaultLakehouse) (string, error)

func (RealAPIClient) TriggerRefresh

func (RealAPIClient) TriggerRefresh(token, workspaceID, datasetID string, tables []string) (string, error)

func (RealAPIClient) UpdateItemDefinition

func (RealAPIClient) UpdateItemDefinition(token, workspaceID, itemID string, def *fabric.Definition) error

func (RealAPIClient) WaitForRefresh

func (RealAPIClient) WaitForRefresh(token, workspaceID, datasetID, requestID string) (fabric.RefreshStatus, error)

type TaggedNotebook

type TaggedNotebook struct {
	Notebook  fabric.Item
	Workspace WorkspaceRef
}

TaggedNotebook is a Fabric notebook plus the workspace it lives in. Used by aggregating flows where an env spans multiple workspaces and the picker needs to disambiguate same-named notebooks.

type WorkspaceRef

type WorkspaceRef struct {
	Name string
	ID   string
}

WorkspaceRef pairs a Fabric workspace display name with its resolved UUID. Run / Refresh / Favourites all need both: the name for display in pickers and error messages, the UUID for API calls.

Directories

Path Synopsis
fetch-nb authenticates against Fabric, resolves a workspace and notebook by displayName, and prints the parameters discovered by futils's parser.
fetch-nb authenticates against Fabric, resolves a workspace and notebook by displayName, and prints the parameters discovered by futils's parser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL