update: better way to handle yes no prompt
This commit is contained in:
parent
013ecfb3e7
commit
0d00678c30
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-05-01 23:04+0300\n"
|
||||
"POT-Creation-Date: 2024-05-02 00:49+0300\n"
|
||||
"PO-Revision-Date: 2024-05-01 13:34+0300\n"
|
||||
"Last-Translator: <ngn@ngn.tf>\n"
|
||||
"Language-Team: Turkish <gnome-turk@gnome.org>\n"
|
||||
@ -56,67 +56,72 @@ msgstr ""
|
||||
msgid "Failed to parse configuration file"
|
||||
msgstr ""
|
||||
|
||||
#: src/log.c:150
|
||||
#: src/log.c:145
|
||||
msgid "y"
|
||||
msgstr ""
|
||||
|
||||
#: src/log.c:150
|
||||
#: src/log.c:145
|
||||
msgid "Y"
|
||||
msgstr ""
|
||||
|
||||
#: src/log.c:152
|
||||
#: src/log.c:146
|
||||
msgid "n"
|
||||
msgstr ""
|
||||
|
||||
#: src/log.c:152
|
||||
#: src/log.c:146
|
||||
msgid "N"
|
||||
msgstr ""
|
||||
|
||||
#: src/log.c:155
|
||||
#: src/log.c:149
|
||||
#, c-format
|
||||
msgid "%s [y/N] "
|
||||
msgstr ""
|
||||
|
||||
#: src/log.c:169
|
||||
msgid "Please answer with y/n"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:74
|
||||
#: src/main.c:72
|
||||
#, c-format
|
||||
msgid "Failed to access paths (%s)"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:82
|
||||
#: src/main.c:80
|
||||
msgid "Failed to lock, mc is already running"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:85
|
||||
#: src/main.c:83
|
||||
msgid "Failed to lock, did you mess up your directory permissions?"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:94
|
||||
#: src/main.c:92
|
||||
#, c-format
|
||||
msgid "%s: command failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:98
|
||||
#: src/main.c:96
|
||||
#, c-format
|
||||
msgid "%s: command successful"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:102
|
||||
#: src/main.c:100
|
||||
#, c-format
|
||||
msgid "MatterLinux Configuration Manager (%s)"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:103
|
||||
#: src/main.c:101
|
||||
msgid "Different operations are done using different commands\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:106
|
||||
#: src/main.c:104
|
||||
msgid "pull down a configuration"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:109
|
||||
#: src/main.c:107
|
||||
msgid "build the configuration in the current directory"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:111
|
||||
#: src/main.c:109
|
||||
msgid ""
|
||||
"Licensed under GPLv3, see <https://www.gnu.org/licenses/> for more "
|
||||
"information"
|
||||
|
28
src/log.c
28
src/log.c
@ -139,18 +139,32 @@ void input(const char *msg, ...) {
|
||||
}
|
||||
|
||||
bool yesno(const char *msg){
|
||||
char question[strlen(msg)+12], inp[2] = {'n','\0'}, c;
|
||||
sprintf(question, "%s [y/n]? ", msg);
|
||||
if(env_mc_yes())
|
||||
return true;
|
||||
|
||||
char *yes[] = {_("y"), _("Y")};
|
||||
char *no[] = {_("n"), _("N")};
|
||||
|
||||
char question[strlen(msg)+12], c;
|
||||
sprintf(question, _("%s [y/N] "), msg);
|
||||
|
||||
while(true){
|
||||
input(question);
|
||||
scanf("%c", &c);
|
||||
inp[0] = c;
|
||||
|
||||
if(eq(inp, _("y")) || eq(inp, _("Y")))
|
||||
return true;
|
||||
else if(eq(inp, _("n")) || eq(inp, _("N")))
|
||||
int c = getchar();
|
||||
if(c == '\n')
|
||||
return false;
|
||||
getchar();
|
||||
|
||||
for(int i = 0; i < sizeof(yes)/sizeof(char*); i++){
|
||||
if(yes[i][0] == c)
|
||||
return true;
|
||||
}
|
||||
|
||||
for(int i = 0; i < sizeof(no)/sizeof(char*); i++){
|
||||
if(no[i][0] == c)
|
||||
return false;
|
||||
}
|
||||
|
||||
error(_("Please answer with y/n"));
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
// clang-format on
|
||||
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
@ -32,14 +31,13 @@
|
||||
|
||||
#include "args.h"
|
||||
#include "gen.h"
|
||||
#include "intl.h"
|
||||
#include "lock.h"
|
||||
#include "log.h"
|
||||
#include "paths.h"
|
||||
#include "pull.h"
|
||||
#include "util.h"
|
||||
|
||||
#define _(x) gettext(x)
|
||||
|
||||
typedef bool (*cmd)();
|
||||
struct CmdMap {
|
||||
char *name;
|
||||
|
Loading…
Reference in New Issue
Block a user