libdragon 10.3.1 → 10.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/modules/usage.js DELETED
@@ -1,129 +0,0 @@
1
- const chalk = require('chalk');
2
- const commandLineUsage = require('command-line-usage');
3
-
4
- const { log } = require('./helpers');
5
-
6
- const printUsage = (_, actionArr) => {
7
- const globalOptionDefinitions = [
8
- {
9
- name: 'verbose',
10
- description: 'Be verbose',
11
- alias: 'v',
12
- group: 'global',
13
- },
14
- ];
15
-
16
- const optionDefinitions = [
17
- {
18
- name: 'image',
19
- description: 'Provide a custom image.',
20
- alias: 'i',
21
- typeLabel: '<docker-image>',
22
- group: 'docker',
23
- },
24
- ];
25
-
26
- const actions = {
27
- help: {
28
- name: 'help [action]',
29
- summary: 'Display this help information or details for the given action.',
30
- },
31
- init: {
32
- name: 'init',
33
- summary: 'Create a libdragon project in the current directory.',
34
- description: `Creates a libdragon project in the current directory. Every libdragon project will have its own docker container instance. If you are in a git repository or an NPM project, libdragon will be initialized at their root also marking there with a \`.libdragon\` folder.
35
-
36
- A git repository and a submodule at \`./libdragon\` will also be created. Do not remove the \`.libdragon\` folder and commit its contents if you are using git, as it keeps persistent libdragon project information.
37
-
38
- If this is the first time you are creating a libdragon project at that location, this action will also create skeleton project files to kickstart things with the given image, if provided. For subsequent runs, it will act like \`start\` thus can be used to revive an existing project without modifying it.`,
39
- group: ['docker'],
40
- },
41
- make: {
42
- name: 'make [params]',
43
- summary: 'Run the libdragon build system in the current directory.',
44
- description: `Runs the libdragon build system in the current directory. It will mirror your current working directory to the container.
45
-
46
- This action is a shortcut to the \`exec\` action under the hood.`,
47
- },
48
- exec: {
49
- name: 'exec <command>',
50
- summary: 'Execute given command in the current directory.',
51
- description: `Executes the given command in the container passing down any arguments provided. If you change your host working directory, the command will be executed in the corresponding folder in the container as well.
52
-
53
- This action will first try to execute the command in the container and if the container is not accessible, it will attempt a complete \`start\` cycle.
54
-
55
- This will properly passthrough your TTY if you have one. So by running \`libdragon exec bash\` you can start an interactive bash session with full TTY support.`,
56
- },
57
- start: {
58
- name: 'start',
59
- summary: 'Start the container for current project.',
60
- description:
61
- 'Start the container assigned to the current libdragon project. Will first attempt to start an existing container if found, followed by a new container run and installation similar to the `install` action. Will always print out the container id on success.',
62
- },
63
- name: {
64
- name: 'stop',
65
- summary: 'Stop the container for current project.',
66
- description:
67
- 'Stop the container assigned to the current libdragon project.',
68
- },
69
- install: {
70
- name: 'install',
71
- summary: 'Vendor libdragon as is.',
72
- group: ['docker'],
73
- description: `Attempts to build and install everything libdragon related into the container. This includes all the tools and third parties used by libdragon except for the toolchain. If you have made changes to libdragon, you can execute this action to build everything based on your changes. Requires you to have an intact \`libdragon\` at the root of the project. If you are not working on libdragon, you can just use the \`update\` action instead.
74
-
75
- This can be useful to recover from a half-baked container.`,
76
- },
77
- update: {
78
- name: 'update',
79
- summary: 'Update libdragon and do an install.',
80
- description:
81
- 'This action will update the submodule from the remote branch (`trunk`) with a merge strategy and then perform a `libdragon install`. You can use the `install` action to only update all libdragon related artifacts in the container.',
82
- group: ['docker'],
83
- },
84
- };
85
-
86
- const actionsToShow = actionArr
87
- ?.filter((action) => Object.keys(actions).includes(action))
88
- .filter((action) => !['help'].includes(action));
89
-
90
- const sections = [
91
- {
92
- header: chalk.green('Usage:'),
93
- content: 'libdragon [flags] <action>',
94
- },
95
- ...(actionsToShow?.length
96
- ? actionsToShow.flatMap((action) => [
97
- {
98
- header: chalk.green(`${action} action:`),
99
- content: actions[action].description,
100
- },
101
- actions[action].group
102
- ? {
103
- header: `accepted flags:`,
104
- optionList: optionDefinitions,
105
- group: actions[action].group,
106
- }
107
- : {},
108
- ])
109
- : [
110
- {
111
- header: chalk.green('Available Commands:'),
112
- content: Object.values(actions).map((action) => ({
113
- name: action.name,
114
- summary: action.summary,
115
- })),
116
- },
117
- ]),
118
- {
119
- header: chalk.green('Global flags:'),
120
- optionList: globalOptionDefinitions,
121
- },
122
- ];
123
- const usage = commandLineUsage(sections);
124
- log(usage);
125
- };
126
-
127
- module.exports = {
128
- printUsage,
129
- };