Documentation
¶
Overview ¶
internal/cmd/list_helper.go
Package cmd provides CLI commands for the notion-cli tool ¶
Package cmd contains the CLI commands for notion-cli.
Index ¶
- Constants
- func ConfigFromContext(ctx context.Context) *config.Config
- func ErrorFormatFromContext(ctx context.Context) string
- func ExitCode(err error) int
- func GetTokenFromContext(ctx context.Context) (string, error)
- func NewListCommand[T any](config ListConfig[T]) *cobra.Command
- func NewNotionClient(ctx context.Context, token string) *notion.Client
- func SkillFileFromContext(ctx context.Context) *skill.SkillFile
- func WithConfig(ctx context.Context, cfg *config.Config) context.Context
- func WithErrorFormat(ctx context.Context, format string) context.Context
- func WithSearchCache(ctx context.Context, cache *SearchCache) context.Context
- func WithSkillFile(ctx context.Context, sf *skill.SkillFile) context.Context
- func WithWorkspace(ctx context.Context, workspace string) context.Context
- func WorkspaceFromContext(ctx context.Context) string
- type App
- type CommandHelp
- type DryRunPrinter
- func (p *DryRunPrinter) Change(name, oldVal, newVal string)
- func (p *DryRunPrinter) Content(name, value string)
- func (p *DryRunPrinter) Field(name, value string)
- func (p *DryRunPrinter) Footer()
- func (p *DryRunPrinter) Header(action, resourceType, id string)
- func (p *DryRunPrinter) Section(title string)
- func (p *DryRunPrinter) Unchanged(name string)
- type EnrichedPage
- type FlagHelp
- type ListConfig
- type ListResult
- type PathEntry
- type ResolveCandidate
- type ResolveResponse
- type SearchCache
- type SubcommandHelp
Constants ¶
const ( // ProxyURL is the OAuth proxy URL ProxyURL = "https://notion-cli.fly.dev" // CallbackTimeout is how long to wait for the OAuth callback CallbackTimeout = 2 * time.Minute )
const ( MinColumnCount = 2 MaxColumnCount = 5 )
Column layout constraints defined by the Notion API.
const ( ExitOK = 0 ExitSystem = 1 ExitUser = 2 ExitAuth = 3 ExitNotFound = 4 ExitRateLimit = 5 ExitTemp = 6 ExitCanceled = 130 )
const NotionMaxPageSize = 100
NotionMaxPageSize is the maximum page size allowed by the Notion API. All paginated endpoints limit page_size to 100.
Variables ¶
This section is empty.
Functions ¶
func ConfigFromContext ¶ added in v0.5.9
ConfigFromContext retrieves CLI config from context.
func ErrorFormatFromContext ¶ added in v0.4.0
ErrorFormatFromContext retrieves the error format from context.
func ExitCode ¶ added in v0.5.4
ExitCode maps a command error to a stable process exit code for automation.
func GetTokenFromContext ¶
GetTokenFromContext retrieves the token based on workspace context. If a workspace is specified in context, it gets the workspace-specific token. Otherwise, falls back to the default token retrieval.
func NewListCommand ¶
func NewListCommand[T any](config ListConfig[T]) *cobra.Command
NewListCommand creates a Cobra command from a ListConfig.
func NewNotionClient ¶
NewNotionClient creates a new Notion API client with debug mode enabled if the --debug flag was set.
func SkillFileFromContext ¶ added in v0.5.0
SkillFileFromContext retrieves the skill file from context
func WithConfig ¶ added in v0.5.9
WithConfig stores loaded CLI config in context for downstream helpers.
func WithErrorFormat ¶ added in v0.4.0
WithErrorFormat stores the error format in the context.
func WithSearchCache ¶ added in v0.5.0
func WithSearchCache(ctx context.Context, cache *SearchCache) context.Context
WithSearchCache adds the search cache to context.
func WithSkillFile ¶ added in v0.5.0
WithSkillFile adds the skill file to context
func WithWorkspace ¶
WithWorkspace stores a workspace name in the context
func WorkspaceFromContext ¶
WorkspaceFromContext retrieves the workspace name from the context
Types ¶
type App ¶ added in v0.4.0
App owns CLI wiring and execution configuration.
func (*App) RootCommand ¶ added in v0.4.0
RootCommand exposes the root Cobra command for embedding/tests.
type CommandHelp ¶ added in v0.5.25
type CommandHelp struct {
Name string `json:"name"`
Aliases []string `json:"aliases,omitempty"`
Short string `json:"short"`
Long string `json:"long,omitempty"`
Usage string `json:"usage"`
Example string `json:"example,omitempty"`
Flags []FlagHelp `json:"flags,omitempty"`
Subcommands []SubcommandHelp `json:"subcommands,omitempty"`
}
CommandHelp represents machine-readable command documentation.
type DryRunPrinter ¶
type DryRunPrinter struct {
// contains filtered or unexported fields
}
DryRunPrinter helps format dry-run output consistently across commands.
func NewDryRunPrinter ¶
func NewDryRunPrinter(w io.Writer) *DryRunPrinter
NewDryRunPrinter creates a new DryRunPrinter that writes to the given writer.
func (*DryRunPrinter) Change ¶
func (p *DryRunPrinter) Change(name, oldVal, newVal string)
Change prints a field that would change from one value to another. Example: Status: "In Progress" -> "Done"
func (*DryRunPrinter) Content ¶
func (p *DryRunPrinter) Content(name, value string)
Content prints multi-line content with proper indentation. Example: Content: "This is the block content..."
func (*DryRunPrinter) Field ¶
func (p *DryRunPrinter) Field(name, value string)
Field prints a single field with its value. Example: Type: paragraph
func (*DryRunPrinter) Footer ¶
func (p *DryRunPrinter) Footer()
Footer prints the footer message indicating no changes were made.
func (*DryRunPrinter) Header ¶
func (p *DryRunPrinter) Header(action, resourceType, id string)
Header prints the header line indicating the action that would be taken. Example: [DRY-RUN] Would delete block abc-123
func (*DryRunPrinter) Section ¶
func (p *DryRunPrinter) Section(title string)
Section prints a section header. Example: Properties to update:
func (*DryRunPrinter) Unchanged ¶
func (p *DryRunPrinter) Unchanged(name string)
Unchanged prints a field that would remain unchanged. Example: Priority: (unchanged)
type EnrichedPage ¶ added in v0.5.0
type EnrichedPage struct {
*notion.Page
ParentTitle string `json:"parent_title,omitempty"`
ChildCount int `json:"child_count"`
Path []PathEntry `json:"path,omitempty"`
}
EnrichedPage wraps a Page with additional metadata resolved via extra API calls. parent_title is the resolved title of the parent database or page. child_count is the number of immediate child blocks. path is the breadcrumb path from root to immediate parent.
type FlagHelp ¶ added in v0.5.25
type FlagHelp struct {
Name string `json:"name"`
Shorthand string `json:"shorthand,omitempty"`
Type string `json:"type"`
Default string `json:"default,omitempty"`
Usage string `json:"usage"`
}
FlagHelp represents machine-readable flag documentation.
type ListConfig ¶
type ListConfig[T any] struct { Use string Short string Long string Example string Headers []string RowFunc func(T) []string Fetch func(ctx context.Context, pageSize int) (ListResult[T], error) EmptyMessage string }
ListConfig configures a list command using generics.
type ListResult ¶
ListResult represents a paginated list response.
type PathEntry ¶ added in v0.5.6
type PathEntry struct {
Type string `json:"type"` // "page" or "database"
ID string `json:"id"`
Title string `json:"title,omitempty"`
}
PathEntry represents one ancestor in a page's breadcrumb path.
type ResolveCandidate ¶ added in v0.5.4
type ResolveResponse ¶ added in v0.5.4
type SearchCache ¶ added in v0.5.0
type SearchCache struct {
// contains filtered or unexported fields
}
SearchCache stores search results for the duration of a single command execution. It reduces API calls when the same search is performed multiple times (e.g., batch operations).
func NewSearchCache ¶ added in v0.5.0
func NewSearchCache() *SearchCache
NewSearchCache creates a new empty search cache.
func SearchCacheFromContext ¶ added in v0.5.0
func SearchCacheFromContext(ctx context.Context) *SearchCache
SearchCacheFromContext retrieves the search cache from context, or nil if not present.
func (*SearchCache) Get ¶ added in v0.5.0
func (c *SearchCache) Get(query, filterType string) *notion.SearchResult
Get retrieves a cached search result, returning nil if not found.
func (*SearchCache) Len ¶ added in v0.5.0
func (c *SearchCache) Len() int
Len returns the number of cached entries.
func (*SearchCache) Set ¶ added in v0.5.0
func (c *SearchCache) Set(query, filterType string, result *notion.SearchResult)
Set stores a search result in the cache.
type SubcommandHelp ¶ added in v0.5.25
type SubcommandHelp struct {
Name string `json:"name"`
Aliases []string `json:"aliases,omitempty"`
Short string `json:"short"`
}
SubcommandHelp represents machine-readable subcommand documentation.
Source Files
¶
- aliases.go
- api.go
- api_error_helpers.go
- api_request.go
- app.go
- auth.go
- auto_aliases.go
- block.go
- block_add.go
- bulk.go
- client_helpers.go
- comment.go
- completion.go
- config.go
- context.go
- datasource.go
- datasource_helpers.go
- db.go
- db_backup.go
- db_write.go
- dryrun.go
- error_output.go
- exitcode.go
- fetch.go
- file.go
- flags.go
- help_json.go
- id_resolution_helpers.go
- import.go
- import_csv.go
- io_helpers.go
- json_input_helpers.go
- light_datasource_templates.go
- light_entity_refs.go
- light_list_items.go
- light_page.go
- light_page_properties.go
- light_schema_registry.go
- light_search.go
- list_helper.go
- mcp.go
- mcp_auth.go
- mcp_call.go
- mcp_comment.go
- mcp_db_query.go
- mcp_helpers.go
- mcp_page_edit.go
- mcp_search_fetch.go
- mcp_tools_workspace.go
- notion_client_iface.go
- openclaw_env.go
- page.go
- page_batch.go
- page_duplicate.go
- page_enrich.go
- page_export.go
- page_helpers.go
- page_properties.go
- page_sync.go
- pagination.go
- pagination_helper.go
- print_query_result.go
- proxy_exit_error.go
- query_shorthand.go
- request_contract_helpers.go
- resolve.go
- resolve_cmd.go
- root.go
- root_prerun.go
- schema.go
- search.go
- simplify.go
- skill.go
- user.go
- webhook.go
- workers.go
- workspace.go