|
| 1 | +package xyz.e3ndr.jeofetch; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | + |
| 5 | +import lombok.Getter; |
| 6 | +import picocli.CommandLine; |
| 7 | +import picocli.CommandLine.Command; |
| 8 | +import picocli.CommandLine.Option; |
| 9 | +import xyz.e3ndr.consoleutil.ConsoleUtil; |
| 10 | +import xyz.e3ndr.consoleutil.input.InputKey; |
| 11 | +import xyz.e3ndr.consoleutil.input.KeyHook; |
| 12 | +import xyz.e3ndr.consoleutil.input.KeyListener; |
| 13 | + |
| 14 | +@Getter |
| 15 | +@Command(name = "print", mixinStandardHelpOptions = true, version = ":^)", description = "Prints a neofetch-esque report") |
| 16 | +public class Bootstrap implements Runnable { |
| 17 | + |
| 18 | + @Option(names = { |
| 19 | + "-H", |
| 20 | + "--hide" |
| 21 | + }, description = "Hides sensitive information") |
| 22 | + private boolean hideSensitive = false; |
| 23 | + |
| 24 | + @Option(names = { |
| 25 | + "-na", |
| 26 | + "--no-art" |
| 27 | + }, description = "Disables art") |
| 28 | + private boolean noArt = false; |
| 29 | + |
| 30 | + @Option(names = { |
| 31 | + "-nc", |
| 32 | + "--no-color" |
| 33 | + }, description = "Disables color and formatting") |
| 34 | + private boolean noColor = false; |
| 35 | + |
| 36 | + @Option(names = { |
| 37 | + "-s", |
| 38 | + "--stay" |
| 39 | + }, description = "Stays on screen until you press a key") |
| 40 | + private boolean stay = false; |
| 41 | + |
| 42 | + @Option(names = { |
| 43 | + "-f", |
| 44 | + "--force" |
| 45 | + }, description = "Forces a piece of art to be on screen") |
| 46 | + private String forced = null; |
| 47 | + |
| 48 | + public static void main(String[] args) { |
| 49 | +// try { |
| 50 | +// ConsoleUtil.summonConsoleWindow(); |
| 51 | +// } catch (IOException | InterruptedException e) {} |
| 52 | + |
| 53 | + new CommandLine(new Bootstrap()).execute(args); |
| 54 | + } |
| 55 | + |
| 56 | + @Override |
| 57 | + public void run() { |
| 58 | + if (System.getProperty("StartedWithConsole", "").equals("true")) { |
| 59 | + try { |
| 60 | + this.stay = true; |
| 61 | + ConsoleUtil.setTitle("Jeofetch"); |
| 62 | + } catch (IOException | InterruptedException e) {} |
| 63 | + } |
| 64 | + |
| 65 | + try { |
| 66 | + Jeofetch.print(this); |
| 67 | + } catch (Throwable t) { |
| 68 | + t.printStackTrace(); |
| 69 | + } |
| 70 | + |
| 71 | + if (this.stay) { |
| 72 | + KeyHook.addListener(new KeyListener() { |
| 73 | + @Override |
| 74 | + public void onKey(char key, boolean alt, boolean control) { |
| 75 | + System.exit(0); |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public void onKey(InputKey key) { |
| 80 | + System.exit(0); |
| 81 | + } |
| 82 | + }); |
| 83 | + |
| 84 | + try { |
| 85 | + Thread.sleep(Long.MAX_VALUE); |
| 86 | + } catch (InterruptedException e) {} |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | +} |
0 commit comments