~schnouki/watch_tabnine

4076911226008dfe650c03411652fa0f2dfea4d9 — Thomas Jost 5 years ago 77f9dbf
Add one-shot mode
3 files changed, 9 insertions(+), 1 deletions(-)

M .build.yml
M README.md
M watch_tabnine.d
M .build.yml => .build.yml +2 -0
@@ 9,9 9,11 @@ tasks:
      cd watch_tabnine
      dmd --version
      make clean all
      ./watch_tabnine -1
      mv watch_tabnine watch_tabnine.dmd
  - build_ldc2: |
      cd watch_tabnine
      ldc2 --version
      make DC=ldc2 clean all
      ./watch_tabnine -1
      mv watch_tabnine watch_tabnine.ldc2

M README.md => README.md +1 -0
@@ 38,6 38,7 @@ watch_tabnine supports several command line options:
- `-m`, `--mem`: max allowed memory in MB (default: 250 MB)
- `-s`, `--swap`: max allowed swap in MB (default: 100 MB)
- `-w`, `--wait`: delay between each check in seconds (default: 30s)
- `-1`, `--once`: only run once


## License

M watch_tabnine.d => watch_tabnine.d +6 -1
@@ 37,6 37,7 @@ string TabNineExecutableName = "TabNine";
uint MemThreshold = 250;
uint SwapThreshold = 100;
uint CheckInterval = 30;
bool OneShot = false;

uint parseSize(string size) pure {
    // In /proc/.../status, sizes are always in kB. Let's blindly convert them


@@ 120,7 121,9 @@ void main(string[] args)
        "name|n", format!"Name of the TabNine executable. [%s]"(TabNineExecutableName), &TabNineExecutableName,
        "mem|m",  format!"Max allowed memory (in MB). [%d]"(MemThreshold), &MemThreshold,
        "swap|s", format!"Max allowed swap (in MB). [%d]"(SwapThreshold), &SwapThreshold,
        "wait|w", format!"Delay between each check (in seconds). [%d]"(CheckInterval), &CheckInterval);
        "wait|w", format!"Delay between each check (in seconds). [%d]"(CheckInterval), &CheckInterval,
        "once|1", "Only run once.", &OneShot,
    );
    if (helpInfo.helpWanted) {
        defaultGetoptPrinter(
            "watch_tabnine ensures that TabNine will not eat all your memory.",


@@ 130,6 133,8 @@ void main(string[] args)

    while(true) {
        run();
        if (OneShot)
            break;
        Thread.sleep(seconds(CheckInterval));
    }
}