Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Removed autorun function (Not needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
xastrix committed Oct 16, 2024
1 parent da2f846 commit 4105170
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 70 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ This is a command line tool designed for swift translation between languages by
lswap r/run --log
With logging (Displaying nontranslated and translated results)
lswap c/config <source_lang> <target_lang>
lswap c/config <SourceLanguage> <TargetLanguage>
Change the source and target languages in the configuration file
lswap ar/autorun --on/--off
Enable or Disable the autorun feature for the application
```
## Showcase
#### RU > EN
Expand Down
23 changes: 2 additions & 21 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ int main(int argc, const char** argv)
fmt{ fmt_def, fc_none, "%s r/run --log\n", LSWAP_APPLICATION_NAME };
fmt{ fmt_def, fc_cyan, " With logging (Displaying nontranslated and translated results)\n\n" };

fmt{ fmt_def, fc_none, "%s c/config <source_lang> <target_lang>\n", LSWAP_APPLICATION_NAME };
fmt{ fmt_def, fc_cyan, " Change the source and target languages in the configuration file\n\n" };

fmt{ fmt_def, fc_none, "%s ar/autorun --on/--off\n", LSWAP_APPLICATION_NAME };
fmt{ fmt_def, fc_cyan, " Enable or Disable the autorun feature for the application\n" };
fmt{ fmt_def, fc_none, "%s c/config <SourceLanguage> <TargetLanguage>\n", LSWAP_APPLICATION_NAME };
fmt{ fmt_def, fc_cyan, " Change the source and target languages in the configuration file\n" };
} };

cli.add("r/run", [](int ac, arguments_t args) {
Expand Down Expand Up @@ -73,21 +70,5 @@ int main(int argc, const char** argv)
}
});

cli.add("ar/autorun", [](int ac, arguments_t args) {
if (ac == 1 && args[1] == "--on") {
if (utils::add_to_autorun(true)) {
fmt{ fmt_30ms, fc_green, "%s successfully added to autorun", LSWAP_APPLICATION_NAME };
}
}
else if (ac == 1 && args[1] == "--off") {
if (utils::add_to_autorun(false)) {
fmt{ fmt_30ms, fc_green, "%s successfully removed from autorun", LSWAP_APPLICATION_NAME };
}
}
else {
fmt{ fmt_30ms, fc_none, "Invalid Arguments. Usage: %s ar/autorun --on/--off", LSWAP_APPLICATION_NAME };
}
});

return cli.parse(argc, argv);
}
38 changes: 0 additions & 38 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,8 @@
#include "utils.h"
#include "../common.h"

#include <unordered_map>
#include <codecvt>

bool utils::add_to_autorun(bool v)
{
char reg_path[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY k{};

LSTATUS status = RegCreateKeyEx(HKEY_CURRENT_USER, reg_path, 0, NULL,
REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &k, NULL);

if (status == ERROR_SUCCESS)
{
if (v)
{
std::string path(MAX_PATH, '\0');
GetModuleFileName(NULL, &path[0], MAX_PATH);

status = RegSetValueEx(k, LSWAP_APPLICATION_NAME, 0,
REG_SZ, reinterpret_cast<const BYTE*>(path.c_str()), path.length() + 1);

if (status == ERROR_SUCCESS) {
RegCloseKey(k);
return true;
}
}
else
{
status = RegDeleteValue(k, LSWAP_APPLICATION_NAME);

if (status == ERROR_SUCCESS) {
RegCloseKey(k);
return true;
}
}
}

return false;
}

std::wstring utils::remove_chars(const std::wstring& str, const std::wstring& chars)
{
std::vector<wchar_t> chars_to_remove;
Expand Down
7 changes: 0 additions & 7 deletions src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@

namespace utils
{
/*
* Function adding the ability to add a program to autorun
* @param boolean (true - add, false - remove)
* @return boolean of successful
*/
bool add_to_autorun(bool v);

/*
* Remove characters from wstring
* @param wstring
Expand Down

0 comments on commit 4105170

Please sign in to comment.