41 HelpEntry(std::string
const& name)
42 : m_msg(
"Flatimage - Portable Linux Applications\n")
45 HelpEntry& with_usage(std::string_view usage)
47 m_msg.append(
"Usage: ").append(usage).append(
"\n");
50 HelpEntry& with_example(std::string_view example)
52 m_msg.append(
"Example: ").append(example).append(
"\n");
55 HelpEntry& with_note(std::string_view note)
57 m_msg.append(
"Note: ").append(note).append(
"\n");
60 HelpEntry& with_description(std::string_view description)
62 m_msg.append(m_name).append(
" : ").append(description).append(
"\n");
65 HelpEntry& with_args(std::vector<std::pair<std::string,std::string>> args)
67 std::ranges::for_each(args, [&](
auto&& e)
69 m_msg += std::string{
" <"} + e.first +
"> : " + e.second +
'\n';
79inline std::string help_usage()
82 .with_description(
"See usage details for specified command")
83 .with_usage(
"fim-help <cmd>")
85 {
"cmd",
"Name of the command to display help details" },
87 .with_note(
"Available commands: fim-{bind,boot,casefold,desktop,env,exec,instance,layer,notify,overlay,perms,recipe,remote,root,unshare,version}")
88 .with_example(R
"(fim-help bind)")
92inline std::string bind_usage()
95 .with_description(
"Bind paths from the host to inside the container")
96 .with_usage(
"fim-bind <add> <type> <src> <dst>")
98 {
"add",
"Create a novel binding of type <type> from <src> to <dst>" },
99 {
"type",
"ro, rw, dev" },
100 {
"src" ,
"A file, directory, or device" },
101 {
"dst" ,
"A file, directory, or device" },
103 .with_usage(
"fim-bind <del> <index>")
105 {
"del",
"Deletes a binding with the specified index" },
106 {
"index" ,
"Index of the binding to erase" },
108 .with_usage(
"fim-bind <list>")
110 {
"list",
"Lists current bindings"}
115inline std::string boot_usage()
118 .with_description(
"Configure the default startup command")
119 .with_usage(
"fim-boot <set> <command> [args...]")
121 {
"set",
"Execute <command> with optional [args] when FlatImage is launched" },
122 {
"command" ,
"Startup command" },
123 {
"args..." ,
"Arguments for the startup command" },
125 .with_example(R
"(fim-boot set echo test)")
126 .with_usage("fim-boot <show|clear>")
128 {
"show" ,
"Displays the current startup command" },
129 {
"clear" ,
"Clears the set startup command" },
134inline std::string casefold_usage()
137 .with_description(
"Enables casefold for the filesystem (ignore case)")
138 .with_usage(
"fim-casefold <on|off>")
140 {
"on",
"Enables casefold" },
141 {
"off",
"Disables casefold" },
146inline std::string desktop_usage()
149 .with_description(
"Configure the desktop integration")
150 .with_usage(
"fim-desktop <setup> <json-file>")
152 {
"setup",
"Sets up the desktop integration with an input json file" },
153 {
"json-file",
"Path to the json file with the desktop configuration"},
155 .with_usage(
"fim-desktop <enable> [entry,mimetype,icon,none]")
157 {
"enable",
"Enables the desktop integration selectively" },
158 {
"entry",
"Enables the start menu desktop entry"},
159 {
"mimetype",
"Enables the mimetype"},
160 {
"icon",
"Enables the icon for the file manager and desktop entry"},
161 {
"none",
"Disables desktop integrations"},
163 .with_usage(
"fim-desktop <clean>")
165 {
"clean",
"Cleans the desktop integration files from XDG_DATA_HOME" },
167 .with_usage(
"fim-desktop <dump> <icon> <file>")
169 {
"dump",
"Dumps the selected integration data" },
170 {
"icon",
"Dumps the desktop icon to a file" },
171 {
"file",
"Path to the icon file, the extension is appended automatically if not specified" },
173 .with_usage(
"fim-desktop <dump> <entry|mimetype>")
175 {
"dump",
"Dumps the selected integration data" },
176 {
"entry",
"The desktop entry of the application" },
177 {
"mimetype",
"The mime type of the application" },
182inline std::string env_usage()
185 .with_description(
"Define environment variables in FlatImage")
186 .with_usage(
"fim-env <add|set> <'key=value'...>")
188 {
"add",
"Include a novel environment variable" },
189 {
"set",
"Redefines the environment variables as the input arguments" },
190 {
"'key=value'...",
"List of variables to add or set" },
192 .with_example(
"fim-env add 'APP_NAME=hello-world' 'HOME=/home/my-app'")
193 .with_usage(
"fim-env <del> <keys...>")
195 {
"del",
"Delete one or more environment variables" },
196 {
"keys...",
"List of variable names to delete" },
198 .with_example(
"fim-env del APP_NAME HOME")
199 .with_usage(
"fim-env <list>")
201 {
"list",
"Lists configured environment variables" },
203 .with_usage(
"fim-env <clear>")
205 {
"clear",
"Clears configured environment variables" },
210inline std::string exec_usage()
213 .with_description(
"Executes a command as a regular user")
214 .with_usage(
"fim-exec <program> [args...]")
216 {
"program",
"Name of the program to execute, it can be the name of a binary or the full path" },
217 {
"args...",
"Arguments for the executed program" },
219 .with_example(R
"(fim-exec echo -e "hello\nworld")")
223inline std::string instance_usage()
226 .with_description(
"Manage running instances")
227 .with_usage(
"fim-instance <exec> <id> [args...]")
229 {
"exec",
"Run a command in a running instance" },
230 {
"id" ,
"ID of the instance in which to execute the command" },
231 {
"args" ,
"Arguments for the 'exec' command" },
233 .with_example(
"fim-instance exec 0 echo hello")
234 .with_usage(
"fim-instance <list>")
236 {
"list",
"Lists current instances" },
241inline std::string layer_usage()
244 .with_description(
"Manage the layers of the current FlatImage")
245 .with_usage(
"fim-layer <create> <in-dir> <out-file>")
247 {
"create",
"Creates a novel layer from <in-dir> and save in <out-file>" },
248 {
"in-dir",
"Input directory to create a novel layer from"},
249 {
"out-file" ,
"Output file name of the layer file"},
251 .with_usage(
"fim-layer <add> <in-file>")
253 {
"add",
"Includes the novel layer <in-file> in the image in the top of the layer stack" },
254 {
"in-file",
"Path to the layer file to include in the FlatImage"},
256 .with_usage(
"fim-layer <commit> <binary|layer|file> [path]")
258 {
"commit",
"Compresses current changes into a layer" },
259 {
"binary",
"Appends the layer to the FlatImage binary" },
260 {
"layer",
"Saves the layer to $FIM_DIR_DATA/layers with auto-increment naming" },
261 {
"file",
"Saves the layer to the specified file path" },
262 {
"path",
"File path (required when using 'file' mode)" },
264 .with_usage(
"fim-layer <list>")
266 {
"list",
"Lists all embedded and external layers in the format index:offset:size:path" },
271inline std::string notify_usage()
274 .with_description(
"Notify with 'notify-send' when the program starts")
275 .with_usage(
"fim-notify <on|off>")
277 {
"on",
"Turns on notify-send to signal the application start" },
278 {
"off",
"Turns off notify-send to signal the application start" },
283inline std::string overlay_usage()
286 .with_description(
"Show or select the default overlay filesystem")
287 .with_usage(
"fim-overlay <set> <overlayfs|unionfs|bwrap>")
289 {
"set",
"Sets the default overlay filesystem to use" },
290 {
"overlayfs",
"Uses 'fuse-overlayfs' as the overlay filesystem" },
291 {
"unionfs",
"Uses 'unionfs-fuse' as the overlay filesystem" },
292 {
"bwrap",
"Uses 'bubblewrap' native overlay options as the overlay filesystem" },
294 .with_usage(
"fim-overlay <show>")
296 {
"show",
"Shows the current overlay filesystem" },
301inline std::string perms_usage()
304 .with_description(
"Edit current permissions for the flatimage")
305 .with_note(
"Permissions: all,audio,dbus_system,dbus_user,dev,gpu,home,input,media,network,optical,shm,udev,usb,wayland,xorg")
306 .with_usage(
"fim-perms <add|del|set> <perms...>")
308 {
"add",
"Allow one or more permissions" },
309 {
"del",
"Delete one or more permissions" },
310 {
"set",
"Replace all permissions with the specified set" },
311 {
"perms...",
"One or more permissions" },
313 .with_example(
"fim-perms add home,network,gpu")
314 .with_example(
"fim-perms set wayland,audio,network")
315 .with_note(
"The 'all' permission sets all available permissions and cannot be combined with other permissions")
316 .with_usage(
"fim-perms <list|clear>")
318 {
"list",
"Lists the current permissions" },
319 {
"clear",
"Clears all permissions" },
324inline std::string remote_usage()
327 .with_description(
"Configure the remote URL for recipes")
328 .with_usage(
"fim-remote <set> <url>")
330 {
"set",
"Set the remote URL" },
331 {
"url",
"The remote URL to configure" },
333 .with_example(
"fim-remote set https://updates.example.com/repo")
334 .with_usage(
"fim-remote <show>")
336 {
"show",
"Display the current remote URL" },
338 .with_usage(
"fim-remote <clear>")
340 {
"clear",
"Clear the configured remote URL" },
345inline std::string recipe_usage()
348 .with_description(
"Fetch, inspect, and install recipes from a remote repository")
349 .with_usage(
"fim-recipe <fetch> <recipes>")
351 {
"fetch",
"Download one or more recipes with their dependencies without installing packages" },
352 {
"recipes",
"Name(s) of the recipe(s) to download (comma-separated for multiple)" },
354 .with_note(
"Recipes and all dependencies are downloaded from URL/DISTRO/latest/<recipe>.json to path_dir_host_config/recipes/DISTRO/latest/<recipe>.json")
355 .with_example(R
"(fim-recipe fetch gpu)")
356 .with_example(R"(fim-recipe fetch gpu,audio,xorg)")
357 .with_usage("fim-recipe <info> <recipes>")
359 {
"info",
"Display information about one or more locally cached recipes including dependencies" },
360 {
"recipes",
"Name(s) of the recipe(s) to inspect (comma-separated for multiple)" },
362 .with_example(R
"(fim-recipe info gpu)")
363 .with_example(R"(fim-recipe info gpu,audio,xorg)")
364 .with_usage("fim-recipe <install> <recipes>")
366 {
"install",
"Download recipes with dependencies, validate no cycles exist, and install all packages" },
367 {
"recipes",
"Name(s) of the recipe(s) to install (comma-separated for multiple)" },
369 .with_note(
"The remote URL must be configured using 'fim-remote set <url>'")
370 .with_note(
"Dependencies are resolved recursively and cyclic dependencies are detected")
371 .with_example(R
"(fim-recipe install gpu)")
372 .with_example(R"(fim-recipe install gpu,audio,xorg)")
376inline std::string root_usage()
379 .with_description(
"Executes a command as the root user")
380 .with_usage(
"fim-root <program> [args...]")
382 {
"program",
"Name of the program to execute, it can be the name of a binary or the full path" },
383 {
"args...",
"Arguments for the executed program" },
385 .with_example(R
"(fim-root id -u)")
389inline std::string unshare_usage()
392 .with_description(
"Configure namespace unsharing options for isolation")
393 .with_note(
"Unshare options: all,user,ipc,pid,net,uts,cgroup")
394 .with_note(
"USER and CGROUP use '-try' variants in bubblewrap for permissiveness")
395 .with_usage(
"fim-unshare <add|del|set> <options...>")
397 {
"add",
"Enable one or more unshare options" },
398 {
"del",
"Remove one or more unshare options" },
399 {
"set",
"Replace all unshare options with the specified set" },
400 {
"options...",
"One or more unshare options (comma-separated)" },
402 .with_example(
"fim-unshare add ipc,pid")
403 .with_example(
"fim-unshare set user,ipc,net")
404 .with_note(
"The 'all' option enables all available unshare options and cannot be combined with others")
405 .with_usage(
"fim-unshare <list|clear>")
407 {
"list",
"Lists the current unshare options" },
408 {
"clear",
"Clears all unshare options" },
413inline std::string version_usage()
416 .with_description(
"Displays version information of FlatImage")
417 .with_usage(
"fim-version <short|full|deps>")
419 {
"short",
"Displays the version as a string" },
420 {
"full",
"Displays the version and build information in json" },
421 {
"deps",
"Displays dependencies metadata in json" },
Help system and command documentation.
Value< std::vector< std::string > > get(fs::path const &path_file_binary)
Get existing variables from the database.