Skip to content

Commit

Permalink
Daily works
Browse files Browse the repository at this point in the history
  • Loading branch information
UIMSolutions committed Jan 14, 2025
1 parent 06f2552 commit 5802140
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 70 deletions.
46 changes: 23 additions & 23 deletions commands/uim/commands/classes/consoles/help.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ class DHelpCommand : DConsoleCommand { // }, ICommandCollectionAware {
}

// Main auto Prints out the list of commands.
/* override */ bool execute(Json[string] arguments, DConsole aConsole) {
/* override */ bool execute(Json[string] arguments, DConsole console) {
/* auto commandIterator = _commands.getIterator();
if (cast(DArrayIterator) commandIterator) {
commandIterator.ksort();
}
if (commandArguments.getOption("xml")) {
this.asXml(aConsole, commandIterator);
this.asXml(console, commandIterator);
return true;
}
asText(aConsole, commandIterator);
asText(console, commandIterator);
*/
return true;
}

// Output text.
protected void asText(DConsole aConsole, string[string] commandCollection) {
protected void asText(DConsole console, string[string] commands) {
string[][string] inverts = null;
commands.byKeyValue
/* commands.byKeyValue
.map!(nameCommand => nameCommand.value.classname)
.each!(classname => inverts.require(classname, null));
.each!(classname => inverts.require(classname, null)); */
// inverts[classname).concat(name);

auto anGrouped = null;
Expand Down Expand Up @@ -72,28 +72,28 @@ class DHelpCommand : DConsoleCommand { // }, ICommandCollectionAware {
});
// ksort(anGrouped);

/* outputPaths(aConsole);
aConsole.out("<info>Available Commands:</info>", 2);
/* outputPaths(console);
console.out("<info>Available Commands:</info>", 2);
*/
/* foreach (prefix, names; anGrouped) {
aConsole.out("<info>%s</info>:".format(prefix));
console.out("<info>%s</info>:".format(prefix));
auto sortedNames = names.sort;
foreach (someData; sortedNames) {
aConsole.out(" - " ~ someData.getString("name"));
console.out(" - " ~ someData.getString("name"));
if (auto description = someData.get("description", null)) {
aConsole.info(str_pad(" \u{2514}", 13, "\u{2500}") ~ " " ~ description.get!string);
console.info(str_pad(" \u{2514}", 13, "\u{2500}") ~ " " ~ description.get!string);
}
}
aConsole.out("");
console.out("");
} */
string root = rootName();
/* aConsole.out("To run a command, type <info>`{root} command_name [args|options]`</info>");
aConsole.out("To get help on a specific command, type <info>`{root} command_name --help`</info>", 2);
/* console.out("To run a command, type <info>`{root} command_name [args|options]`</info>");
console.out("To get help on a specific command, type <info>`{root} command_name --help`</info>", 2);
*/
}

// Output relevant paths if defined
protected void outputPaths(DConsole aConsole) {
protected void outputPaths(DConsole console) {
STRINGAA myPaths;

if (configuration.hasKey("App.dir")) {
Expand All @@ -110,29 +110,29 @@ class DHelpCommand : DConsoleCommand { // }, ICommandCollectionAware {
if (!count(myPaths)) {
return;
} */
/* aConsole.out("<info>Current Paths:</info>", 2);
myPaths.each!(kv => aConsole.out("* %s: %s".format(kv.key, kv.value)));
aConsole.out(""); */
/* console.out("<info>Current Paths:</info>", 2);
myPaths.each!(kv => console.out("* %s: %s".format(kv.key, kv.value)));
console.out(""); */
}



// Output as XML
protected void asXml(DConsole aConsole, DCommand[string] commands) {
protected void asXml(DConsole console, DCommand[string] commands) {
STRINGAA names;
/* commands.byKeyValue
.each!(nameCommand => names[nameCommand.key] = nameCommand.value); */

/* asXml(aConsole, names); */
/* asXml(console, names); */
}

/* protected void asXml(DConsole aConsole, string[string] commandNames) {
/* protected void asXml(DConsole console, string[string] commandNames) {
auto shells = new DSimpleXMLElement("<shells></shells>");
commandNames.byKeyValue
.each(nameclassname => shells.addCommandToShells(nameclassname.key, nameclassname.value));
/* aConsole.setOutputAs(DOutput.RAW);
aConsole.out(castto!string(xmlShells.saveXML())); * /
/* console.setOutputAs(DOutput.RAW);
console.out(castto!string(xmlShells.saveXML())); * /
} */

// TODO
Expand Down
24 changes: 12 additions & 12 deletions commands/uim/commands/classes/i18n/i18nextract.d
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class DI18nExtractCommand : DCommand {
* Takes care of duplicate translations
*/
protected void _addTranslation(string domainName, string messageId, Json[string] contextData = null) {
auto context = contextData.get("msgctxt", "");
/* auto context = contextData.get("msgctxt", "");
if (isEmpty(_translations[domainName][messageId][context])) {
_translations.setPath([domainName, messageId, context], [
Expand All @@ -218,7 +218,7 @@ class DI18nExtractCommand : DCommand {
_translations.append([
domainName, messageId, context, "references", contextData["file"]
], line);
}
} */
}

// Extract text
Expand Down Expand Up @@ -304,11 +304,11 @@ class DI18nExtractCommand : DCommand {

// Extract tokens out of all files to be processed
protected void _extractTokens(Json[string] commandArguments, IConsole console) {
auto progress = console.helper("progress");
/* auto progress = console.helper("progress");
assert(cast(ProgressHelper) progress);
progress.initialize(["total": count(_fileNames)]);
bool isVerbose = commandArguments.getOption("verbose");
bool isVerbose = commandArguments.getBoolean("verbose"); */

auto functions = [
"__": ["singular"],
Expand Down Expand Up @@ -407,7 +407,7 @@ class DI18nExtractCommand : DCommand {
// Build the translate template file contents out of obtained strings
protected void _buildFiles(Json[string] consoleArguments) {
auto somePaths = _paths;
somePaths ~= realpath(APP) ~ DIRECTORY_SEPARATOR;
/* somePaths ~= realpath(APP) ~ DIRECTORY_SEPARATOR; */

/* usort(somePaths, auto (string aa, string ab) {
return a.length - b.length;
Expand Down Expand Up @@ -456,17 +456,17 @@ class DI18nExtractCommand : DCommand {

// Prepare a file to be stored
protected void _store(string domainName, string headerContent, string sentenceToStore) {
_storage.set(domainName, _storage.get(domainName));
/* _storage.set(domainName, _storage.get(domainName));
_storage.setPath([domainName, sentence],
_storage.hasKeyPath([domainName, sentence])
? _storage.getStringPath([domainName, sentence]) ~ headerContent : headerContent
);
); */
}

// Write the files that need to be stored
protected void _writeFiles(Json[string] commandArguments, IConsole console) {
console.writeln();
/* console.writeln(); */
bool overwriteAll = false;
/* if (commandArguments.getOption("overwrite")) {
overwriteAll = true;
Expand Down Expand Up @@ -509,8 +509,8 @@ class DI18nExtractCommand : DCommand {

// Build the translation template header
protected string _writeHeader(string domainName) {
string projectIdVersion = domainName == "uim"
? "UIM " ~ Configure.currentVersion() : "PROJECT VERSION";
string projectIdVersion; /* = domainName == "uim"
? "UIM " ~ Configure.currentVersion() : "PROJECT VERSION"; */

string result = "# LANGUAGE translation of UIM Application\n";
result ~= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n";
Expand All @@ -537,9 +537,9 @@ class DI18nExtractCommand : DCommand {
* Compares the sha1 hashes of the old and new file without header.
*/
protected bool checkUnchanged(string oldFile, int lengthOfFileheader, string newFileContent) {
if (!filehasKey(oldFile)) {
/* if (!filehasKey(oldFile)) {
return false;
}
} */

/* auto oldFileContent = file_get_contents(oldFile);
if (oldFileContent == false) {
Expand Down
24 changes: 12 additions & 12 deletions commands/uim/commands/classes/i18n/i18ninit.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ class DI18nInitCommand : DCommand {
return "i18n-init";
}

override bool execute(Json[string] arguments, IConsole consoleIo) {
auto myLanguage = commandArguments.getArgument("language");
override bool execute(Json[string] arguments, IConsole console) {
/* auto myLanguage = commandArguments.getArgument("language");
if (myLanguage.isNull) {
myLanguage = consoleIo.ask(
myLanguage = console.ask(
"Please specify language code, e.g. `en`, `eng`, `en_US` etc.");
}
if (myLanguage.length < 2) {
consoleIo.writeErrorMessages(
console.writeErrorMessages(
"Invalid language code. Valid is `en`, `eng`, `en_US` etc.");
return false;
}
} */

auto somePaths = App.path("locales");
/* auto somePaths = App.path("locales");
if (arguments.hasKey("plugin")) {
plugin = arguments.getString("plugin").camelize;
somePaths = [
Plugin.path(
plugin) ~ "resources" ~ DIRECTORY_SEPARATOR ~ "locales" ~ DIRECTORY_SEPARATOR
];
}
} */

string response = consoleIo.ask("What folder?", stripRight(somePaths[0], DIRECTORY_SEPARATOR) ~ DIRECTORY_SEPARATOR);
/* string response = console.ask("What folder?", stripRight(somePaths[0], DIRECTORY_SEPARATOR) ~ DIRECTORY_SEPARATOR);
string sourceFolder = stripRight(response, DIRECTORY_SEPARATOR) ~ DIRECTORY_SEPARATOR;
string targetFolder = sourceFolder ~ myLanguage ~ DIRECTORY_SEPARATOR;
/* if (!isDir(targetFolder)) {
*//* if (!isDir(targetFolder)) {
mkdir(targetFolder, 0770, true);
} */
size_t countFiles = 0;
/* size_t countFiles = 0;
auto anIterator = new DirectoryIterator(sourceFolder);
anIterator
.filter!(fileInfo => fileInfo.isFile())
Expand All @@ -61,8 +61,8 @@ class DI18nInitCommand : DCommand {
aConsole.createFile(targetFolder ~ newFilename, content);
countFiles++;
});
consoleIo.writeln("Generated " ~ countFiles ~ " PO files in " ~ targetFolder);

console.writeln("Generated " ~ countFiles ~ " PO files in " ~ targetFolder);
*/
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions commands/uim/commands/classes/plugins/load.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DPluginLoadCommand : DCommand {
}
*/
override bool execute(Json[string] arguments, IConsole console = null) {
auto plugin = arguments.getString("plugin");
/* auto plugin = arguments.getString("plugin");
auto options = null;
if (arguments.hasKey("only-debug")) {
options.set("onlyDebug", true);
Expand All @@ -59,15 +59,15 @@ class DPluginLoadCommand : DCommand {
return false;
}
}
} */
/* result = this.modifyConfigFile(plugin, options);
if (result == false) {
consoleIo.writeErrorMessages("Failed to update `CONFIG/plugins.d`");
}
consoleIo.success("Plugin added successfully to `CONFIG/plugins.d`");
return result; */
return true;
return false;
}

// Modify the plugins config file.
Expand Down
4 changes: 2 additions & 2 deletions commands/uim/commands/classes/plugins/unload.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class DPluginUnloadCommand : DCommand {
override bool execute(Json[string] arguments, IConsole console) {
string pluginName = arguments.getString("plugin");

auto modificationResult = modifyConfigFile(pluginName);
/* auto modificationResult = modifyConfigFile(pluginName);
if (modificationResult.isNull) {
console.success("Plugin removed from `CONFIG/plugins.d`");
return true;
}
console.writeErrorMessages(modificationResult);
console.writeErrorMessages(modificationResult); */

return false;
}
Expand Down
Loading

0 comments on commit 5802140

Please sign in to comment.