/* * cnhelp - Display cnotes command reference */ #include #include void print_overview(void) { printf("cnotes - Command-line note-taking system\n"); printf("\n"); printf("Commands:\n"); printf(" cnadd Add a new note entry\n"); printf(" cndump Display all notes\n"); printf(" cnfind Search notes\n"); printf(" cncount Show statistics\n"); printf(" cndel Archive (delete) notes\n"); printf(" cnhelp This help message\n"); printf("\n"); printf("Use 'cnhelp ' for details on a specific command.\n"); } void print_cnadd(void) { printf("cnadd - Add a new timestamped note entry\n"); printf("\n"); printf("Usage: cnadd [-c CATEGORY] \"message\"\n"); printf("\n"); printf("Options:\n"); printf(" -c CATEGORY Set category (max 10 chars, default: General)\n"); printf("\n"); printf("Examples:\n"); printf(" cnadd \"Remember to call Bob\"\n"); printf(" cnadd -c Work \"Meeting at 3pm\"\n"); } void print_cndump(void) { printf("cndump - Display all notes in a formatted table\n"); printf("\n"); printf("Usage: cndump [-d] [-c] [-r] [-a]\n"); printf("\n"); printf("Options:\n"); printf(" -d, --date Sort by date/time (newest first)\n"); printf(" -c, --category Sort by category\n"); printf(" -r, --reverse Reverse sort order\n"); printf(" -a, --archive Show archived entries\n"); printf("\n"); printf("Examples:\n"); printf(" cndump Display all notes\n"); printf(" cndump -d Sort by date\n"); printf(" cndump -a Show archived notes\n"); } void print_cnfind(void) { printf("cnfind - Search notes by text, category, or date\n"); printf("\n"); printf("Usage: cnfind [-c CAT] [-d DATE] [-i] [-n] [-a] [PATTERN]\n"); printf("\n"); printf("Options:\n"); printf(" -c CATEGORY Filter by category\n"); printf(" -d DATE Filter by date (YYYY-MM-DD)\n"); printf(" -i Case-sensitive search\n"); printf(" -n Show only match count\n"); printf(" -a, --archive Search archived entries\n"); printf("\n"); printf("Examples:\n"); printf(" cnfind meeting Search for 'meeting'\n"); printf(" cnfind -c Work Show Work category\n"); printf(" cnfind -a meeting Search archive\n"); } void print_cncount(void) { printf("cncount - Display note statistics\n"); printf("\n"); printf("Usage: cncount [-c] [-d] [-a]\n"); printf("\n"); printf("Options:\n"); printf(" -c, --category Count by category\n"); printf(" -d, --date Count by date\n"); printf(" -a, --archive Count archived entries\n"); printf("\n"); printf("Examples:\n"); printf(" cncount Total count\n"); printf(" cncount -c Count per category\n"); printf(" cncount -a -c Archived by category\n"); } void print_cndel(void) { printf("cndel - Archive (soft-delete) note entries\n"); printf("\n"); printf("Usage: cndel -n LINE | -d DATE | -l [-y]\n"); printf("\n"); printf("Options:\n"); printf(" -n LINE Archive entry at line number\n"); printf(" -d DATE Archive all entries on date (YYYY-MM-DD)\n"); printf(" -l Archive the last entry\n"); printf(" -y Skip confirmation\n"); printf("\n"); printf("Notes are moved to cnotes.arc, not permanently deleted.\n"); printf("Use cnfind to get line numbers.\n"); printf("\n"); printf("Examples:\n"); printf(" cndel -n 5 Archive line 5\n"); printf(" cndel -l -y Archive last entry (no prompt)\n"); } int main(int argc, char *argv[]) { if (argc < 2) { print_overview(); return 0; } if (strcmp(argv[1], "cnadd") == 0 || strcmp(argv[1], "add") == 0) { print_cnadd(); } else if (strcmp(argv[1], "cndump") == 0 || strcmp(argv[1], "dump") == 0) { print_cndump(); } else if (strcmp(argv[1], "cnfind") == 0 || strcmp(argv[1], "find") == 0) { print_cnfind(); } else if (strcmp(argv[1], "cncount") == 0 || strcmp(argv[1], "count") == 0) { print_cncount(); } else if (strcmp(argv[1], "cndel") == 0 || strcmp(argv[1], "del") == 0) { print_cndel(); } else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { print_overview(); } else { fprintf(stderr, "cnhelp: unknown command '%s'\n", argv[1]); fprintf(stderr, "Available: cnadd, cndump, cnfind, cncount, cndel\n"); return 1; } return 0; }