Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Hide console on search and reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
spikespaz committed Jun 30, 2018
1 parent aed9b39 commit 0a8b719
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
12 changes: 6 additions & 6 deletions deflect.d
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module deflect;

import std.windows.registry : Registry, Key, REGSAM;
import std.process : spawnShell;
import std.string : replace, indexOf, toLower, startsWith;
import std.array : split;
import std.stdio : writeln, readln;
import std.uri : decodeComponent, encodeComponent;
import std.windows.registry: Registry, Key, REGSAM;
import std.process: spawnShell;
import std.string: replace, indexOf, toLower, startsWith;
import std.array: split;
import std.stdio: writeln, readln;
import std.uri: decodeComponent, encodeComponent;

// Function to run after setup, actually deflected.
void deflect(const string uri) {
Expand Down
14 changes: 8 additions & 6 deletions main.d
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
module main;

import std.stdio : writeln, readln;
import std.stdio: writeln, readln;
import setup: setup;
import deflect: deflect;

import core.sys.windows.windows: ShowWindow, GetConsoleWindow, SW_HIDE;

void main(string[] args) {
if (args.length > 1) { // A URL has been passed, deflect it.
import deflect : deflect;

ShowWindow(GetConsoleWindow(), SW_HIDE);
deflect(args[1]);
}
else { // There has been no arguments. The user is probably wanting to set up.
try {
import setup : setup;

setup(args[0]);
}
catch (Exception error) {
writeln("\nThe SearchDeflector setup has crashed. Try running the executable as administrator.\n",
writeln(
"\nThe SearchDeflector setup has crashed. Try running the executable as administrator.\n",
"If the problem persists, please copy the error below and submit an issue on GitHub.\n",
"https://github.com/spikespaz/search-deflector/issues\n\n",
"=== BEGIN CRASH EXCEPTION ===\n\n", error, "\n\n=== END CRASH EXCEPTION ===");
Expand Down
16 changes: 8 additions & 8 deletions setup.d
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module setup;

import std.stdio : write, writeln, readln;
import std.algorithm.sorting : sort;
import std.range : array, enumerate;
import std.array : split;
import std.net.curl : get, CurlException;
import std.conv : parse, ConvException;
import std.string : toLower, strip, splitLines, indexOf, stripLeft;
import std.windows.registry : Key, Registry, REGSAM, RegistryException;
import std.stdio: write, writeln, readln;
import std.algorithm.sorting: sort;
import std.range: array, enumerate;
import std.array: split;
import std.net.curl: get, CurlException;
import std.conv: parse, ConvException;
import std.string: toLower, strip, splitLines, indexOf, stripLeft;
import std.windows.registry: Key, Registry, REGSAM, RegistryException;

// Online resource to the repository of the project containing a list of search engine choices.
immutable string enginesURL = "https://raw.githubusercontent.com/spikespaz/search-deflector/master/engines.txt";
Expand Down
20 changes: 20 additions & 0 deletions updater.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module updater;

import std.json;
import std.net.curl;
import std.stdio: writeln;

const string releases = "https://api.github.com/repos/spikespaz/search-deflector/releases";

void main() {
writeln(getLatestRelease());
}

string[string] getLatestRelease() {
const JSONValue response = parseJSON(get(releases));

return ["tag" : response["tag_name"].str, // "name": response["name"].toString(),
// "url": response["url"].toString(),
// "file": response["assets"][0]["url"].toString()
];
}

0 comments on commit 0a8b719

Please sign in to comment.