mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
Refactor commandline handling
- instead of having the list of commandline arguments, their handlers and their help strings in different places, unify them in a single array - this allows to only change one piece of code when adding new arguments
This commit is contained in:
35
cmd_help.c
35
cmd_help.c
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Bryan Christ <bryan.christ@mediafire.com>
|
||||
* 2014 Johannes Schauer <j.schauer@email.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2, as published by
|
||||
@@ -26,8 +27,8 @@
|
||||
#include "private.h"
|
||||
#include "command.h"
|
||||
|
||||
void
|
||||
mfshell_cmd_help(void)
|
||||
int
|
||||
mfshell_cmd_help(mfshell_t *mfshell, int argc, char **argv)
|
||||
{
|
||||
printf(
|
||||
" arguments:\n\r"
|
||||
@@ -36,26 +37,22 @@ mfshell_cmd_help(void)
|
||||
|
||||
printf("\n\r");
|
||||
|
||||
printf(
|
||||
" help show this help\n\r"
|
||||
" debug show debug information\n\r"
|
||||
int column1_width = 0;
|
||||
int column2_width = 0;
|
||||
|
||||
" host <server> change target server\n\r"
|
||||
" auth authenticate with active server\n\r"
|
||||
" whoami show basic user info\n\r"
|
||||
_cmd_t* curr_cmd;
|
||||
for (curr_cmd = mfshell->commands; curr_cmd->name != NULL; curr_cmd++) {
|
||||
if (strlen(curr_cmd->name) > column1_width)
|
||||
column1_width = strlen(curr_cmd->name);
|
||||
if (strlen(curr_cmd->argstring) > column2_width)
|
||||
column2_width = strlen(curr_cmd->argstring);
|
||||
}
|
||||
|
||||
" ls show contents of active folder\n\r"
|
||||
" cd [folderkey] change active folder\n\r"
|
||||
" pwd show the active folder\n\r"
|
||||
" lpwd show the local working directory\n\r"
|
||||
" lcd [dir] change the local working directory\n\r"
|
||||
" mkdir [folder name] create a new folder\n\r"
|
||||
for (curr_cmd = mfshell->commands; curr_cmd->name != NULL; curr_cmd++) {
|
||||
printf("%*s %*s %s\n", column1_width, curr_cmd->name, column2_width, curr_cmd->argstring, curr_cmd->help);
|
||||
}
|
||||
|
||||
" file [quickkey] show file information\n\r"
|
||||
" links [quickkey] show access urls for the file\n\r"
|
||||
" get [quickkey] download a file\n\r");
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user