Skip to content

Commit

Permalink
Merge snap-user-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
tejohnso committed Jun 21, 2018
2 parents 59b73d1 + 9f3723f commit 165a8ea
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
28 changes: 14 additions & 14 deletions dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
using namespace std;

void populate_dictionary_from_args(set<string> &, int, char *[]);
void populate_dictionary_from_file(set<string> &, 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<string> &);

bool populate_dictionary(set<string> &dict, int argc, char *argv[]) {
void populate_dictionary(set<string> &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<string> &dict, int argc, char *argv[]) {
copy(argv + 1, argv + argc, inserter(dict, dict.end()));
}

void populate_dictionary_from_file(set<string> &dict, const char *homedir) {
string filePath;
void populate_dictionary_from_file(set<string> &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<string>(file), istream_iterator<string>(), inserter(dict, dict.end()));
if (dict.size() == 0) {throw runtime_error("Provide " + FILE_PATH + " or arguments.");}
}
2 changes: 1 addition & 1 deletion dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

using namespace std;

bool populate_dictionary(set<string>&, int, char *[]);
void populate_dictionary(set<string>&, int, char *[]);

#endif
2 changes: 1 addition & 1 deletion fdic.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 165a8ea

Please sign in to comment.