add a help page tool for reference
This commit is contained in:
parent
6ab92f96b9
commit
347c39412b
@ -30,6 +30,10 @@ ECHO Compiling cnfind.exe...
|
||||
TCC -A -w -ml -I.\include -ebuild\cnfind.exe src\cnfind.c
|
||||
IF ERRORLEVEL 1 GOTO ERROR
|
||||
|
||||
ECHO Compiling cnhelp.exe...
|
||||
TCC -A -w -ml -I.\include -ebuild\cnhelp.exe src\cnhelp.c
|
||||
IF ERRORLEVEL 1 GOTO ERROR
|
||||
|
||||
ECHO.
|
||||
ECHO Build successful!
|
||||
ECHO.
|
||||
|
||||
@ -25,3 +25,4 @@ add_executable(cndump src/cndump.c)
|
||||
add_executable(cncount src/cncount.c)
|
||||
add_executable(cndel src/cndel.c)
|
||||
add_executable(cnfind src/cnfind.c)
|
||||
add_executable(cnhelp src/cnhelp.c)
|
||||
|
||||
@ -23,7 +23,7 @@ BUILDDIR = build
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) -c -o$*.obj $<
|
||||
|
||||
all: $(BUILDDIR) $(BUILDDIR)\cnadd.exe $(BUILDDIR)\cndump.exe $(BUILDDIR)\cncount.exe $(BUILDDIR)\cndel.exe $(BUILDDIR)\cnfind.exe
|
||||
all: $(BUILDDIR) $(BUILDDIR)\cnadd.exe $(BUILDDIR)\cndump.exe $(BUILDDIR)\cncount.exe $(BUILDDIR)\cndel.exe $(BUILDDIR)\cnfind.exe $(BUILDDIR)\cnhelp.exe
|
||||
|
||||
$(BUILDDIR):
|
||||
if not exist $(BUILDDIR) mkdir $(BUILDDIR)
|
||||
@ -43,6 +43,9 @@ $(BUILDDIR)\cndel.exe: $(SRCDIR)\cndel.c $(INCDIR)\platform.h $(INCDIR)\config.h
|
||||
$(BUILDDIR)\cnfind.exe: $(SRCDIR)\cnfind.c $(INCDIR)\platform.h $(INCDIR)\config.h
|
||||
$(CC) $(CFLAGS) -e$(BUILDDIR)\cnfind.exe $(SRCDIR)\cnfind.c
|
||||
|
||||
$(BUILDDIR)\cnhelp.exe: $(SRCDIR)\cnhelp.c
|
||||
$(CC) $(CFLAGS) -e$(BUILDDIR)\cnhelp.exe $(SRCDIR)\cnhelp.c
|
||||
|
||||
clean:
|
||||
if exist $(BUILDDIR)\*.exe del $(BUILDDIR)\*.exe
|
||||
if exist $(BUILDDIR)\*.obj del $(BUILDDIR)\*.obj
|
||||
|
||||
10
Makefile
10
Makefile
@ -9,10 +9,10 @@ SRCDIR = src
|
||||
INCDIR = include
|
||||
BUILDDIR = build
|
||||
|
||||
SOURCES = $(SRCDIR)/cnadd.c $(SRCDIR)/cndump.c $(SRCDIR)/cncount.c $(SRCDIR)/cndel.c $(SRCDIR)/cnfind.c
|
||||
SOURCES = $(SRCDIR)/cnadd.c $(SRCDIR)/cndump.c $(SRCDIR)/cncount.c $(SRCDIR)/cndel.c $(SRCDIR)/cnfind.c $(SRCDIR)/cnhelp.c
|
||||
HEADERS = $(INCDIR)/platform.h $(INCDIR)/config.h
|
||||
|
||||
TARGETS = $(BUILDDIR)/cnadd $(BUILDDIR)/cndump $(BUILDDIR)/cncount $(BUILDDIR)/cndel $(BUILDDIR)/cnfind
|
||||
TARGETS = $(BUILDDIR)/cnadd $(BUILDDIR)/cndump $(BUILDDIR)/cncount $(BUILDDIR)/cndel $(BUILDDIR)/cnfind $(BUILDDIR)/cnhelp
|
||||
|
||||
.PHONY: all clean install uninstall
|
||||
|
||||
@ -36,6 +36,9 @@ $(BUILDDIR)/cndel: $(SRCDIR)/cndel.c $(HEADERS)
|
||||
$(BUILDDIR)/cnfind: $(SRCDIR)/cnfind.c $(HEADERS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $(SRCDIR)/cnfind.c
|
||||
|
||||
$(BUILDDIR)/cnhelp: $(SRCDIR)/cnhelp.c
|
||||
$(CC) $(CFLAGS) -o $@ $(SRCDIR)/cnhelp.c
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
|
||||
@ -46,6 +49,7 @@ install: $(TARGETS)
|
||||
install -m 755 $(BUILDDIR)/cncount /usr/local/bin/
|
||||
install -m 755 $(BUILDDIR)/cndel /usr/local/bin/
|
||||
install -m 755 $(BUILDDIR)/cnfind /usr/local/bin/
|
||||
install -m 755 $(BUILDDIR)/cnhelp /usr/local/bin/
|
||||
|
||||
uninstall:
|
||||
rm -f /usr/local/bin/cnadd /usr/local/bin/cndump /usr/local/bin/cncount /usr/local/bin/cndel /usr/local/bin/cnfind
|
||||
rm -f /usr/local/bin/cnadd /usr/local/bin/cndump /usr/local/bin/cncount /usr/local/bin/cndel /usr/local/bin/cnfind /usr/local/bin/cnhelp
|
||||
|
||||
10
README.md
10
README.md
@ -135,6 +135,16 @@ Options:
|
||||
|
||||
The output includes line numbers for use with `cndel -n`.
|
||||
|
||||
### cnhelp
|
||||
|
||||
Quick reference for all cnotes commands.
|
||||
|
||||
```bash
|
||||
cnhelp # show command overview
|
||||
cnhelp cnadd # help for cnadd
|
||||
cnhelp dump # help for cndump (short form)
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Notes Location
|
||||
|
||||
136
src/cnhelp.c
Normal file
136
src/cnhelp.c
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* cnhelp - Display cnotes command reference
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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 <command>' 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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user