ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_cli_usage.c
Go to the documentation of this file.
1
9#include "mdl_cli.h"
10#include "mdl_cli_internal.h"
11#include "ra8_attributes.h"
12
31 const char* a0)
32{
33 const char* const parts[] = {
34 " series:\n"
35 " ",
36 a0,
37 " --config SITE.conf --series URL [--chapters N] [--from CHAP]\n"
38 " [--update] [--out DIR] [--cache-dir DIR] [--format FMT] [--separate] [--seed S]\n"
39 " [--timeout MS]\n"
40 " Formats: cbz|cbt|cbt.gz|epub|jof|rabook\n"
41 " Default: N chapters combine into ONE <slug>-<lo>-<hi>.<ext>.\n"
42 " --separate keeps one archive per chapter.\n"
43 " --from CHAP starts at chapter NUMBERED CHAP (not an index).\n"
44 " --update fetches only incomplete chapters.\n\n"
45 " search:\n"
46 " ",
47 a0,
48 " --config SITE.conf --search TERM [--pick N ...opts]\n"
49 " Lists title + series URL per hit.\n"
50 " --pick N downloads hit N directly using --series options.\n\n"
51 " browse:\n"
52 " ",
53 a0,
54 " --config SITE.conf --browse [--pick N ...opts]\n"
55 " Lists site's latest updates (requires browse_url in conf).\n\n"
56 " library:\n"
57 " ",
58 a0,
59 " --list | --update-all --config SITE.conf | --remove URL|SLUG [--out DIR]\n\n",
60 };
61 return priv_mdl_cli_put_parts(diagnostic, parts, sizeof(parts) / sizeof(parts[0]));
62}
63
82 const char* a0)
83{
84 const char* const parts[] = {
85 " verify:\n"
86 " ",
87 a0,
88 " --verify [DIR]\n"
89 " Verify existing downloaded archives/files.\n\n"
90 " init-site:\n"
91 " ",
92 a0,
93 " --init-site URL\n"
94 " Generate starter .conf site descriptor template.\n\n"
95 " pack:\n"
96 " ",
97 a0,
98 " --pack DIR --format FMT\n"
99 " Package an existing folder of page images (no network).\n\n"
100 " direct artifact:\n"
101 " ",
102 a0,
103 " https://HOST/PATH/BOOK.cbz [--out DIR] [network options]\n"
104 " Downloads to staging and publishes only after structural\n"
105 " verification. Verified formats: cbz|cbt|cbt.gz|epub|jof|rabook.\n\n"
106 " page:\n"
107 " ",
108 a0,
109 " URL [--out DIR] [--max N] [--attr data-src|src] [--seed S]\n"
110 " [--timeout MS]\n\n",
111 };
112 return priv_mdl_cli_put_parts(diagnostic, parts, sizeof(parts) / sizeof(parts[0]));
113}
114
132{
133 return ra8_io_stream_puts(
134 diagnostic,
135 " identity / politeness / network options:\n"
136 " --contact <email|url> Identify yourself in the User-Agent\n"
137 " --polite Raise delays; per-host concurrency 1\n"
138 " --progress Terminal progress bar during downloads\n"
139 " --cache-dir <DIR> Per-host cache root (default: OUT/.mdl_cache)\n"
140 " --refetch Force cache revalidation\n"
141 " --proxy <URL> HTTP/HTTPS proxy (requires --allow-private)\n"
142 " --socks5 <URL> SOCKS5 proxy (requires --allow-private)\n"
143 " --cookie-file <FILE> Cookie file path for libcurl\n"
144 " --ca-file <FILE> Custom PEM CA bundle (verification stays on)\n"
145 " --max-bytes N Per-response size cap (default 64 MiB)\n"
146 " --ignore-robots Do NOT honour robots.txt (logged loudly)\n"
147 " --allow-private Permit loopback/private/link-local peers\n"
148 " --cross-host Permit redirects to a different host\n"
149 " --allow-incomplete Package run with failed pages; archive\n"
150 " is named .INCOMPLETE so it is visibly partial\n");
151}
152
153ra8_err_t mdl_cli_usage(ra8_io_stream_t* diagnostic, const char* a0)
154{
155 if ((diagnostic == nullptr) || (a0 == nullptr)) {
156 return k_ra8_err_null_ptr;
157 }
158 const char* const heading[] = {"usage:\n ", a0, " --help | --version\n\n"};
159 ra8_err_t err = priv_mdl_cli_put_parts(diagnostic, heading, sizeof(heading) / sizeof(heading[0]));
160 if (err == k_ra8_ok) {
161 err = internal_cli_usage_discovery(diagnostic, a0);
162 }
163 if (err == k_ra8_ok) {
164 err = internal_cli_usage_actions(diagnostic, a0);
165 }
166 if (err == k_ra8_ok) {
167 err = internal_cli_usage_network_options(diagnostic);
168 }
169 return err;
170}
Command-line parsing for the mdl CLI.
Private byte-stream helpers shared by mdl CLI units.
ra8_err_t priv_mdl_cli_put_parts(ra8_io_stream_t *stream, const char *const *parts, size_t count)
Write a bounded ordered vector of NUL-terminated text fragments.
static ra8_err_t internal_cli_usage_actions(ra8_io_stream_t *diagnostic, const char *a0)
Write verify, init, pack, artifact, and direct-page help sections.
static ra8_err_t internal_cli_usage_network_options(ra8_io_stream_t *diagnostic)
Write the identity, politeness, and network CLI options.
static ra8_err_t internal_cli_usage_discovery(ra8_io_stream_t *diagnostic, const char *a0)
Write series, discovery, and library help sections.
ra8_err_t mdl_cli_usage(ra8_io_stream_t *diagnostic, const char *a0)
Write the complete usage block to an injected byte stream.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
Definition ra8_err.h:478
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_err_t ra8_io_stream_puts(ra8_io_stream_t *s, const char *str)
Write a NUL-terminated string (without the NUL) to the bound sink.
Caller-allocated byte-stream handle binding a sink to its context.