Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Libcoincellhell
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
Libcoincellhell
Commits
a84f1e0e
Commit
a84f1e0e
authored
1 year ago
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
improve cli application help
parent
ff6b89b4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.c
+29
-1
29 additions, 1 deletion
main.c
with
29 additions
and
1 deletion
main.c
+
29
−
1
View file @
a84f1e0e
...
...
@@ -70,12 +70,28 @@ static channel_t char_to_channel(char ch)
}
}
void
print_commands
(
void
)
{
puts
(
"Valid commands:"
);
puts
(
"connect [CHANNEL]
\t
| connect a channels"
);
puts
(
"disconnect [CHANNEL]
\t
| disconnect a channels"
);
puts
(
"clear
\t\t\t
| disconnect all channels"
);
puts
(
"connect_all
\t\t
| connect all channels"
);
puts
(
"get
\t\t\t
| get the state of all channels"
);
puts
(
"read [ADDRESS] [LENGTH]
\t
| read from the device eeprom at address"
);
puts
(
"write [ADDRESS] [LENGTH] | write to the device eeprom at address"
);
}
static
int
process_commands
(
char
**
commands
,
size_t
command_count
,
struct
eismultiplexer
*
multiplexer
,
char
*
name
)
{
if
(
strcmp
(
commands
[
0
],
"clear"
)
==
0
)
{
eismultiplexer_disconnect_channel
(
multiplexer
,
CHANNEL_NONE
);
}
else
if
(
strcmp
(
commands
[
0
],
"help"
)
==
0
)
{
print_commands
();
}
else
if
(
strcmp
(
commands
[
0
],
"write"
)
==
0
)
{
if
(
command_count
<
3
)
...
...
@@ -147,7 +163,7 @@ static int process_commands(char** commands, size_t command_count, struct eismul
{
if
(
command_count
!=
2
)
{
p
rintf
(
"Usage %s %s [CHANNEL]
\n
"
,
name
,
commands
[
0
]
);
p
uts
(
"A channel is required"
);
return
2
;
}
...
...
@@ -174,6 +190,12 @@ static int process_commands(char** commands, size_t command_count, struct eismul
return
3
;
}
}
else
{
printf
(
"%s is not a valid command
\n
"
,
commands
[
0
]);
print_commands
();
return
3
;
}
}
return
0
;
}
...
...
@@ -215,6 +237,12 @@ int main(int argc, char* argv[])
struct
config
config
=
{};
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
config
);
if
(
config
.
list_commands
)
{
print_commands
();
return
0
;
}
if
(
config
.
command_count
<
1
&&
!
(
config
.
interactive
||
config
.
pipe
))
{
printf
(
"A command is required
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment