Skip to content

Commit

Permalink
Add the following flags to the fast-p binary
Browse files Browse the repository at this point in the history
--version, --clear-cache, --help
  • Loading branch information
Corey Penford authored and Corey Penford committed Jul 9, 2019
1 parent d25431f commit 7d6b07c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ The first run of the command will take some time to cache the text extracted fro

# How to clear the cache?

To clear the cache (which contains text extracted from PDF), you may safely remove the file
``~/.cache/fast-p-pdftotext-output/fast-p_cached_pdftotext_output.db``, or
``~/.cache/fast-p_cached_pdftotext_output.db`` in older version.
To clear the cache (which contains text extracted from PDF), you can run 'fast-p --clear-cache'. This will safely remove the file located at:
``~/.cache/fast-p-pdftotext-output/fast-p_cached_pdftotext_output.db``

For older versions, please manually delete the cache file found at
``~/.cache/fast-p_cached_pdftotext_output.db``

# Launch with keyboard shortcut in Ubuntu

Expand Down
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"flag"
"path/filepath"
"os/exec"
"bufio"
Expand All @@ -32,6 +33,25 @@ func hash_file_xxhash(filePath string) (string, error) {
}

func main() {
version := flag.Bool("version", false, "Display program version")
clearCache := flag.Bool("clear-cache", false, "Delete cache file located at: \n~/.cache/fast-p-pdftotext-output/fast-p_cached_pdftotext_output.db")
flag.Parse()

if *version != false {
fmt.Printf("v.0.2.4 \nhttps://github.com/bellecp/fast-p\n")
os.Exit(0)
}

if *clearCache !=false {
removePath, err := homedir.Expand("~/.cache/fast-p-pdftotext-output/fast-p_cached_pdftotext_output.db")
if err != nil {
log.Fatal(err)
os.Exit(1)
}
os.Remove(removePath)
os.Exit(0)
}

// Create ~/.cache folder if does not exist
// https://stackoverflow.com/questions/37932551/mkdir-if-not-exists-using-golang
cachePath, err := homedir.Expand("~/.cache/fast-p-pdftotext-output/")
Expand Down

0 comments on commit 7d6b07c

Please # to comment.