OmniStacksStaticModules 2.0.0
Loading...
Searching...
No Matches
anonymous_namespace{main.cpp} Namespace Reference

Classes

struct  Runtime
 一次进程调用共享的根目录、数据库路径和默认 Inbox 工作区。 More...

Enumerations

enum class  ExitCode : int { ok = 0 , usage = 1 , failed = 2 }

Functions

std::expected< std::monostate, interface_log::LogError > initialize_log (const std::filesystem::path &path)
 初始化 bqlog,并临时把 stdout 指向 stderr。
fs::path executable_directory (const char *argv0)
 解析 argv[0] 的绝对目录;weakly_canonical 失败时回退到 absolute。
fs::path find_source_root (fs::path start)
 源码运行时向上查找 CMakeLists.txt,作为项目根目录。
bool environment_flag (std::string_view name, bool fallback)
 Alfred 布尔变量的宽容解析。
std::optional< std::string > ensure_runtime_layout (const fs::path &root)
 首次运行补齐 data/log 和三个空 JSON。
Runtime discover_runtime (const char *argv0)
 发现运行根目录、workflow 目录和默认 Inbox。
void print_usage ()
 打印完整 CLI 帮助;仅用于终端调试,不进入 Alfred Script Filter 输出。
void print_task (const TaskManager::TaskRecord &task)
 任务列表行的稳定 TSV 格式,便于 awk/人工调试。
int run_sync (const Runtime &runtime, const fs::path &path)
 CLI sync:把新工作区交给 ProjectSync,并输出项目/清单统计。
int run_add (const Runtime &runtime, const std::string &target, const std::string &payload, const std::vector< std::string > &values)
 CLI add:向项目或清单创建任务。
int run_inbox (const Runtime &runtime, const std::string &payload, const std::vector< std::string > &values)
 CLI inbox:在默认/显式工作区创建收件箱任务。
std::vector< std::string > arguments (int argc, char *argv[], int start)
 从 argv[start..] 复制额外参数;start 之后的参数所有权仍属于进程。
std::optional< std::string > option_value (const std::vector< std::string > &values, std::string_view option)
 返回第一个 --option value 的值;缺失返回 nullopt。
bool has_option (const std::vector< std::string > &values, std::string_view option)
 检查布尔开关参数是否存在,例如 --dry-run、--todo-only。
int run_boards (const Runtime &runtime, std::string query)
 CLI boards:按显示名/ID 过滤项目与清单。
int run_tasks (const Runtime &runtime, const std::vector< std::string > &values)
 CLI tasks:把 –board/–query/–todo-only 映射为过滤条件。
int run_week (const Runtime &runtime, std::optional< std::string > anchor)
 CLI week:返回指定锚点周的未完成截止任务。
int run_get (const Runtime &runtime, const std::string &id)
 CLI get:输出单个任务的 Stacks 兼容字段。
int run_edit (const Runtime &runtime, const std::string &id, const std::vector< std::string > &values)
 CLI edit:构造三态 TaskPatch 并写回任务。
template<typename Result>
int print_task_result (const std::string &command, const Result &result)
 统一打印各种 expected 任务操作结果。
ReminderSync::Provider parse_provider_or_default (const std::string &value, bool *valid)
 将 provider 文本解析为枚举;invalid 通过输出参数报告,避免抛异常。
int run_sync_reminder (const Runtime &runtime, const std::string &id, const std::string &provider_text, bool dry_run)
 CLI sync-reminder:读取任务快照并同步到指定外部应用。
int run_sync_week (const Runtime &runtime, const std::string &provider_text, bool dry_run)
 CLI sync-week:逐个同步本周截止任务。
int run_ui (const Runtime &runtime, const std::string &query)
 CLI ui:把查询交给 WorkflowUI。
int run_action (const Runtime &runtime, const std::string &token)
 CLI action:执行 Alfred 选中的 action token。

Enumeration Type Documentation

◆ ExitCode

enum class anonymous_namespace{main.cpp}::ExitCode : int
strong
Enumerator
ok 

命令完成。

usage 

参数不足或未知命令。

failed 

可恢复业务/IO 失败。

Definition at line 28 of file main.cpp.

Function Documentation

◆ arguments()

std::vector< std::string > anonymous_namespace{main.cpp}::arguments ( int argc,
char * argv[],
int start )

从 argv[start..] 复制额外参数;start 之后的参数所有权仍属于进程。

Definition at line 345 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discover_runtime()

Runtime anonymous_namespace{main.cpp}::discover_runtime ( const char * argv0)

发现运行根目录、workflow 目录和默认 Inbox。

Note
包内运行时以 info.plist/data 判定;源码运行时向上查找 CMakeLists.txt。

Definition at line 161 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensure_runtime_layout()

std::optional< std::string > anonymous_namespace{main.cpp}::ensure_runtime_layout ( const fs::path & root)

首次运行补齐 data/log 和三个空 JSON。

Returns
成功为空;失败返回可用于 stderr 的路径创建错误。
Note
已存在文件绝不覆盖,发布会话不会清除用户路径或任务。

Definition at line 119 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ environment_flag()

bool anonymous_namespace{main.cpp}::environment_flag ( std::string_view name,
bool fallback )

Alfred 布尔变量的宽容解析。

Note
“空串、0、false、off、unchecked”统一视为关闭;缺失时返回 fallback。

Definition at line 97 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ executable_directory()

fs::path anonymous_namespace{main.cpp}::executable_directory ( const char * argv0)

解析 argv[0] 的绝对目录;weakly_canonical 失败时回退到 absolute。

Definition at line 74 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_source_root()

fs::path anonymous_namespace{main.cpp}::find_source_root ( fs::path start)

源码运行时向上查找 CMakeLists.txt,作为项目根目录。

Definition at line 81 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_option()

bool anonymous_namespace{main.cpp}::has_option ( const std::vector< std::string > & values,
std::string_view option )

检查布尔开关参数是否存在,例如 --dry-run、--todo-only。

Definition at line 365 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize_log()

std::expected< std::monostate, interface_log::LogError > anonymous_namespace{main.cpp}::initialize_log ( const std::filesystem::path & path)

初始化 bqlog,并临时把 stdout 指向 stderr。

Note
bqlog 初始化 banner 只能进入 Alfred Debugger,不能污染 Script Filter JSON。

Definition at line 55 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ option_value()

std::optional< std::string > anonymous_namespace{main.cpp}::option_value ( const std::vector< std::string > & values,
std::string_view option )

返回第一个 --option value 的值;缺失返回 nullopt。

Definition at line 354 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_provider_or_default()

ReminderSync::Provider anonymous_namespace{main.cpp}::parse_provider_or_default ( const std::string & value,
bool * valid )

将 provider 文本解析为枚举;invalid 通过输出参数报告,避免抛异常。

Definition at line 518 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_task()

void anonymous_namespace{main.cpp}::print_task ( const TaskManager::TaskRecord & task)

任务列表行的稳定 TSV 格式,便于 awk/人工调试。

Definition at line 242 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_task_result()

template<typename Result>
int anonymous_namespace{main.cpp}::print_task_result ( const std::string & command,
const Result & result )

统一打印各种 expected 任务操作结果。

Note
if constexpr 分派编译期 Result 类型,避免为每种 CLI 命令重复样板。

Definition at line 493 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_usage()

void anonymous_namespace{main.cpp}::print_usage ( )

打印完整 CLI 帮助;仅用于终端调试,不进入 Alfred Script Filter 输出。

Definition at line 214 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_action()

int anonymous_namespace{main.cpp}::run_action ( const Runtime & runtime,
const std::string & token )

CLI action:执行 Alfred 选中的 action token。

Parameters
runtime当前运行上下文。
tokenWorkflowUI 生成的稳定 token。
Returns
成功 0;领域/解析错误 2。

Definition at line 630 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_add()

int anonymous_namespace{main.cpp}::run_add ( const Runtime & runtime,
const std::string & target,
const std::string & payload,
const std::vector< std::string > & values )

CLI add:向项目或清单创建任务。

Parameters
runtime当前运行根目录与数据库路径。
target项目/清单 ID。
payloadtitle|description。
values--start/--due/--priority 等额外 argv。
Returns
成功 0;领域错误 2。

Definition at line 269 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_boards()

int anonymous_namespace{main.cpp}::run_boards ( const Runtime & runtime,
std::string query )

CLI boards:按显示名/ID 过滤项目与清单。

Parameters
runtime当前运行上下文。
query空表示全部;否则做简单子串过滤。
Returns
查询成功 0;索引损坏 2。

Definition at line 375 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_edit()

int anonymous_namespace{main.cpp}::run_edit ( const Runtime & runtime,
const std::string & id,
const std::vector< std::string > & values )

CLI edit:构造三态 TaskPatch 并写回任务。

Parameters
runtime当前运行上下文。
id任务 ID。
values--title/--description/--start/--due/--priority/--clear-*。
Returns
成功 0;校验或写回失败 2。

Definition at line 468 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_get()

int anonymous_namespace{main.cpp}::run_get ( const Runtime & runtime,
const std::string & id )

CLI get:输出单个任务的 Stacks 兼容字段。

Parameters
runtime当前运行上下文。
id任务 ID。
Returns
成功 0;任务不存在/不可读 2。

Definition at line 440 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_inbox()

int anonymous_namespace{main.cpp}::run_inbox ( const Runtime & runtime,
const std::string & payload,
const std::vector< std::string > & values )

CLI inbox:在默认/显式工作区创建收件箱任务。

Parameters
runtime当前运行上下文。
payloadtitle|description。
values日期和优先级 argv。
Returns
成功 0;领域错误 2。

Definition at line 312 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_sync()

int anonymous_namespace{main.cpp}::run_sync ( const Runtime & runtime,
const fs::path & path )

CLI sync:把新工作区交给 ProjectSync,并输出项目/清单统计。

Definition at line 249 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_sync_reminder()

int anonymous_namespace{main.cpp}::run_sync_reminder ( const Runtime & runtime,
const std::string & id,
const std::string & provider_text,
bool dry_run )

CLI sync-reminder:读取任务快照并同步到指定外部应用。

Parameters
runtime当前运行上下文。
id任务 ID。
provider_textreminders/omnifocus/both。
dry_run只验证,不执行 AppleScript。
Returns
成功 0;用法错误 1;同步失败 2。

Definition at line 541 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_sync_week()

int anonymous_namespace{main.cpp}::run_sync_week ( const Runtime & runtime,
const std::string & provider_text,
bool dry_run )

CLI sync-week:逐个同步本周截止任务。

Parameters
runtime当前运行上下文。
provider_textreminders/omnifocus/both。
dry_run只验证,不执行外部应用。
Returns
全部成功 0;首个失败或其他用法错误非零。

Definition at line 579 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_tasks()

int anonymous_namespace{main.cpp}::run_tasks ( const Runtime & runtime,
const std::vector< std::string > & values )

CLI tasks:把 –board/–query/–todo-only 映射为过滤条件。

Parameters
runtime当前运行上下文。
valuestasks 命令后的参数列表。
Returns
成功 0;索引/任务读取失败 2。

Definition at line 396 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_ui()

int anonymous_namespace{main.cpp}::run_ui ( const Runtime & runtime,
const std::string & query )

CLI ui:把查询交给 WorkflowUI。

Parameters
runtime当前运行上下文。
queryAlfred 原始查询(已完成脚本层别名转换)。
Returns
始终 0;错误已转换为 Alfred JSON 条目。

Definition at line 619 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_week()

int anonymous_namespace{main.cpp}::run_week ( const Runtime & runtime,
std::optional< std::string > anchor )

CLI week:返回指定锚点周的未完成截止任务。

Parameters
runtime当前运行上下文。
anchor可选 YYYY-MM-DD;空表示今天。
Returns
成功 0;查询失败 2。

Definition at line 422 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: