diff --git a/.circleci/config.yml b/.circleci/config.yml index 95313b1..29d0dbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,11 +7,11 @@ jobs: steps: - checkout - run: - name: Verify required tags and changelog update + name: Verify required tags and changelog update for non branch channels command: | git tag --contains |grep [0-9]\\.[0-9]\\.[0-9] git tag --contains |grep edge || git tag --contains |grep stable - git diff HEAD^1 HEAD --stat --name-only |grep ^CHANGELOG.md$ + if git tag --contains |grep ^edge$ || git tag --contains |grep ^stable$; then git diff HEAD^1 HEAD --stat --name-only |grep ^CHANGELOG.md$; fi - run: name: Set version @@ -49,8 +49,8 @@ jobs: - run: name: Push/release snap command: | - if git tag --contains |grep edge; then snapcraft push *.snap --release edge; fi - if git tag --contains |grep stable; then snapcraft push *.snap --release stable; fi + if git tag --contains |grep edge; then snapcraft push *.snap --release $(git tag --contains |grep edge |tr -d "\n" |tr "+" "/"); fi + if git tag --contains |grep stable; then snapcraft push *.snap --release $(git tag --contains |grep stable |tr -d "\n" |tr "+" "/"); fi - run: name: Confirm release @@ -106,22 +106,22 @@ workflows: branches: ignore: /.*/ tags: - only: /stage|edge/ + only: /stable|edge.*/ - release_snap: filters: tags: - only: /stage|edge/ + only: /stable|edge.*/ requires: - build - release_aur: filters: tags: - only: /stage|edge/ + only: /stable|edge/ requires: - build - release_github: filters: tags: - only: /stage|edge/ + only: /stable|edge/ requires: - build diff --git a/CHANGELOG.md b/CHANGELOG.md index 0087be2..3a93e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Allow min/max wordlength cli options - Check default ubuntu dict paths +## [1.0.8] - 2018-06-19 +### Added +- Use confined snap user dir for dictionary + ## [1.0.7] - 2018-06-19 ### Added - Improved release process diff --git a/README.md b/README.md index d9d60ef..cd3e71c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ FDIC will read STDIN and output newline delimited words to stdout if they are contained in a dictionary file at *~/.config/fdic/dict.txt* +or *~/snap/fdic/common/dict.txt* Alternatively, the dictionary can be specified on the command line `./fdic word1 word2 word3` diff --git a/dictionary.cpp b/dictionary.cpp index 9f0e0ff..95f7a27 100644 --- a/dictionary.cpp +++ b/dictionary.cpp @@ -10,33 +10,33 @@ using namespace std; void populate_dictionary_from_args(set &, int, char *[]); -void populate_dictionary_from_file(set &, const char *); -const string NO_DICTIONARY_ERROR = "No dictionary found in $HOME/.config/fdic/dict.txt " - "and no words provided as command line arguments."; +void populate_dictionary_from_file(set &); -bool populate_dictionary(set &dict, int argc, char *argv[]) { +void populate_dictionary(set &dict, int argc, char *argv[]) { if (argc > 1) { populate_dictionary_from_args(dict, argc, argv); } else { - populate_dictionary_from_file(dict, getenv("HOME")); + populate_dictionary_from_file(dict); } - - if (dict.size() == 0) {throw runtime_error(NO_DICTIONARY_ERROR);} - - return true; } void populate_dictionary_from_args(set &dict, int argc, char *argv[]) { copy(argv + 1, argv + argc, inserter(dict, dict.end())); } -void populate_dictionary_from_file(set &dict, const char *homedir) { - string filePath; +void populate_dictionary_from_file(set &dict) { + string FILE_PATH; - if (homedir == NULL) { - homedir = getpwuid(getuid())->pw_dir; + if (getenv("SNAP_NAME")) { + string SNAP_USER_COMMON = getenv("SNAP_USER_COMMON"); + FILE_PATH = SNAP_USER_COMMON.append("/dict.txt"); + } else { + string homedir = getenv("HOME"); + if (!homedir.size()) {homedir = getpwuid(getuid())->pw_dir;} + FILE_PATH = homedir.append("/.config/fdic/dict.txt"); } - fstream file(filePath.append(homedir).append("/.config/fdic/dict.txt")); + fstream file (FILE_PATH); copy(istream_iterator(file), istream_iterator(), inserter(dict, dict.end())); + if (dict.size() == 0) {throw runtime_error("Provide " + FILE_PATH + " or arguments.");} } diff --git a/dictionary.h b/dictionary.h index 87e4958..c2fea0d 100644 --- a/dictionary.h +++ b/dictionary.h @@ -5,6 +5,6 @@ using namespace std; -bool populate_dictionary(set&, int, char *[]); +void populate_dictionary(set&, int, char *[]); #endif diff --git a/fdic.1 b/fdic.1 index 9ce7962..c7e0352 100644 --- a/fdic.1 +++ b/fdic.1 @@ -33,7 +33,7 @@ Or, with a dicitionary configured, we can omit the wordlist from the command lin cat /dev/urandom |tr -s -c [:alpha:] "\n" |tr [:upper:] [:lower:] |fdic .SH FILES -~/.config/fdic/dict.txt should contain a list of valid words separated by newlines. +~/.config/fdic/dict.txt or ~/snap/fdic/common/dict.txt should contain a list of valid words separated by newlines. .SH BUGS https://github.com/tejohnso/dictionary-filter/issues