manuals, help text, style fixes

pull/10/head
sobolevn 8 years ago
commit 8d16a0e679

130
.gitignore vendored

@ -0,0 +1,130 @@
#### joe made this: http://goel.io/joe
#####=== Windows ===#####
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
#####=== Linux ===#####
*~
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
#####=== OSX ===#####
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
#####=== JetBrains ===#####
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
#####=== SublimeText ===#####
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# workspace files are user-specific
*.sublime-workspace
# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project
# sftp configuration file
sftp-config.json
#####=== Jekyll ===#####
_site/
.sass-cache/
#####=== Custom ===#####
.gitsecret/
git-secret
vendor/
temp/
# Temporary:
gh-pages/

@ -10,7 +10,7 @@
.
.nf
git secret hide [\-c] [\-v] [\-h]
git secret hide [\-c] [\-v]
.
.fi
.

@ -0,0 +1,30 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-SECRET\-REMOVE" "1" "February 2016" "" ""
.
.SH "NAME"
\fBgit\-secret\-remove\fR \- removes files from index\.
.
.SH "SYNOPSIS"
.
.nf
git secret remove [\-c] <pathspec\.\.>
.
.fi
.
.SH "DESCRIPTION"
\fBgit\-secret\-remove\fR deletes files from \fB\.gitsecret/paths/mapping\.cfg\fR, so they won\'t be encrypted or decrypted in the future\. There\'s also an option to delete existing encrypted versions of the files provided\.
.
.SH "OPTIONS"
.
.nf
\-c \- deletes existing real encrypted files\.
\-h \- shows help\.
.
.fi
.
.SH "SEE ALSO"
git\-secret\-add(1), git\-secret\-reveal(1), git\-secret\-hide(1)

@ -10,7 +10,7 @@
.
.nf
git secret reveal [\-p] [\-d] [\-h]
git secret reveal [\-d dir] [\-p password]
.
.fi
.

@ -10,7 +10,7 @@
.
.nf
git secret tell [\-m] [\-d] [\-h]
git secret tell [\-m] [\-d dir] [email]
.
.fi
.

@ -65,9 +65,15 @@ function _set_config {
# The exit status is 0 (true) if the name was found, 1 (false) if not:
local contains=$(grep -Fq "$1" $3; echo $?)
<<<<<<< HEAD
if [[ "$contains" -eq 0 ]]; then
_os_based __replace_in_file $@
elif [[ "$contains" -eq 1 ]]; then
=======
if [[ $contains -eq 0 ]]; then
_os_based __replace_in_file $@
elif [[ $contains -eq 1 ]]; then
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
echo "$1 = $2" >> "$3"
fi
}
@ -78,7 +84,11 @@ function _file_has_line {
local contains=$(grep -qw "$1" "$2"; echo $?)
# 0 on contains, 1 for error.
<<<<<<< HEAD
echo "$contains";
=======
echo $contains;
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
}

@ -8,18 +8,30 @@ function add {
for item in $@; do
# Checking if all files in options are ignored:
<<<<<<< HEAD
if [[ ! -f "$item" ]]; then
=======
if [[ ! -f $item ]]; then
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
_abort "$item is not a file."
fi
local ignored=$(_check_ignore "$item")
<<<<<<< HEAD
if [[ ! "$ignored" -eq 0 ]]; then
=======
if [[ ! $ignored -eq 0 ]]; then
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
# collect unignored files.
not_ignored+=("$item")
fi
done
<<<<<<< HEAD
if [[ ! "${#not_ignored[@]}" -eq 0 ]]; then
=======
if [[ ! ${#not_ignored[@]} -eq 0 ]]; then
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
# and show them all at once.
_abort "these files are not ignored: ${not_ignored[@]} ;"
fi
@ -27,8 +39,13 @@ function add {
for item in $@; do
# adding files into system, skipping duplicates.
local already_in=$(_file_has_line "$item" "$SECRETS_DIR_PATHS_MAPPING")
<<<<<<< HEAD
if [[ "$already_in" -eq 1 ]]; then
echo "$item" >> "$SECRETS_DIR_PATHS_MAPPING"
=======
if [[ $already_in -eq 1 ]]; then
echo $item >> $SECRETS_DIR_PATHS_MAPPING
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
fi
done

@ -2,6 +2,7 @@
function _show_help_clean {
<<<<<<< HEAD
cat <<-EOF
usage: git secret clean [-v]
removes all the hidden files.
@ -11,6 +12,12 @@ options:
-h shows this help.
EOF
=======
echo "usage: git secret clean"
echo "removes all the hidden files."
echo
echo " -v shows which files are deleted."
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
exit 0
}

@ -2,6 +2,7 @@
function _show_help_hide {
<<<<<<< HEAD
cat <<-EOF
usage: git secret hide [-c] [-v]
encrypts all the files added by the 'add' command.
@ -12,6 +13,13 @@ options:
-h shows this help.
EOF
=======
echo "usage: git secret hide"
echo "encrypts all the files added by the 'add' command."
echo
echo " -c deletes encrypted files before creating new ones."
echo " -v shows which files are deleted."
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
exit 0
}
@ -23,11 +31,25 @@ function _optional_clean {
while getopts "cvh" opt; do
case "$opt" in
<<<<<<< HEAD
c) clean=1;;
h) _show_help_hide;;
v) opt_string="-v";;
=======
c) # -c is used for guaranted clean encryption.
clean=1
;;
h)
_show_help_hide
;;
v)
opt_string="$opt_string -$opt"
;;
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
esac
done
@ -37,7 +59,11 @@ function _optional_clean {
_user_required
if [[ $clean -eq 1 ]]; then
<<<<<<< HEAD
clean "$opt_string"
=======
clean ${opt_string}
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
fi
}

@ -15,6 +15,9 @@ function init {
mkdir "$SECRETS_DIR" "$SECRETS_DIR_KEYS" "$SECRETS_DIR_PATHS"
touch "$SECRETS_DIR_KEYS_MAPPING" "$SECRETS_DIR_PATHS_MAPPING"
<<<<<<< HEAD
=======
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
echo "'${SECRETS_DIR}/' created."
}

@ -2,6 +2,7 @@
function _show_help_remove {
<<<<<<< HEAD
cat <<-EOF
usage: git secret remove [-c] <pathspec..>
removes files from git-secret's index."
@ -11,6 +12,12 @@ options:
-h shows this help.
EOF
=======
echo "usage: git secret remove [files..]"
echo "removes files from git-secret's index."
echo
echo " -c deletes existing real files."
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
exit 0
}
@ -21,9 +28,19 @@ function remove {
while getopts "ch" opt; do
case "$opt" in
<<<<<<< HEAD
c) clean=1;;
h) _show_help_remove;;
=======
c)
clean=1
;;
h)
_show_help_remove
;;
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
esac
done

@ -2,6 +2,7 @@
function _show_help_reveal {
<<<<<<< HEAD
cat <<-EOF
usage: git secret reveal [-d dir] [-p password]
unencrypts all the files added by the 'add' command.
@ -12,6 +13,13 @@ options:
-h shows this help.
EOF
=======
echo "usage: git secret reveal"
echo "unencrypts all the files added by the 'add' command."
echo
echo " -d specifies --homedir option for gpg."
echo " -p specifies password for noinput mode, adds --passphrase option for gpg."
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
exit 0
}
@ -24,11 +32,25 @@ function reveal {
while getopts "hd:p:" opt; do
case "$opt" in
<<<<<<< HEAD
h) _show_help_reveal;;
p) passphrase=$OPTARG;;
d) homedir=$OPTARG;;
=======
h)
_show_help_reveal
;;
p)
passphrase=$OPTARG
;;
d)
homedir=$OPTARG
;;
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
esac
done

@ -1,5 +1,6 @@
#!/usr/bin/env bash
<<<<<<< HEAD
function _show_help_tell {
cat <<-EOF
@ -16,6 +17,8 @@ EOF
}
=======
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
function tell {
_secrets_dir_exists
@ -28,6 +31,7 @@ function tell {
while getopts "h?md:" opt; do
case "$opt" in
<<<<<<< HEAD
h) _show_help_tell;;
m) # Set email of the git current user:
@ -35,6 +39,23 @@ function tell {
;;
d) homedir=$OPTARG;;
=======
h|\?)
usage
;;
m) # Set email of the git current user:
email=$(git config user.email) || email=""
if [[ -z $email ]]; then
_abort "empty email for current git user."
fi
;;
d)
homedir=$OPTARG
;;
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
esac
done
@ -44,21 +65,39 @@ function tell {
# Custom argument-parsing:
if [[ -z $email ]]; then
# Email was not set via `-m` and is in $1:
<<<<<<< HEAD
test ! -z "$1" && email="$1"; shift || _abort "first argument must be an email address."
=======
email="$1"
if [[ -z $email ]]; then
_abort "first argument must be an email address."
fi
shift
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
fi
# This file will be removed automatically:
_temporary_file
<<<<<<< HEAD
local keyfile="$filename"
if [[ -z "$homedir" ]]; then
=======
local keyfile=$filename
if [[ -z $homedir ]]; then
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
$SECRETS_GPG_COMMAND --export -a "$email" > "$keyfile"
else
# It means that homedir is set as an extra argument via `-d`:
$SECRETS_GPG_COMMAND --no-permission-warning --homedir="$homedir" --export -a "$email" > "$keyfile"
fi
<<<<<<< HEAD
if [[ ! -s "$keyfile" ]]; then
=======
if [[ ! -s $keyfile ]]; then
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
_abort 'gpg key is empty. check your key name: `gpg --list-keys`.'
fi

@ -2,14 +2,31 @@
function usage {
<<<<<<< HEAD
local commands=""
local separator="|"
for com in $(compgen -A function); do
=======
if [[ ! -z "$1" ]]; then
echo $@
fi
local commands=""
local separator="|"
for com in $(compgen -A function)
do
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
if [[ ! $com == _* ]]; then
commands+="$com$separator"
fi
done
echo "usage: git secret [${commands%?}]"
<<<<<<< HEAD
=======
exit 0
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
}

@ -7,12 +7,15 @@ function _check_setup {
_abort "repository is broken. try running 'git init' or 'git clone'."
fi
<<<<<<< HEAD
# Checking if the '.gitsecret' is not ignored:
local ignored=$(_check_ignore ".gitsecret/")
if [[ ! $ignored -eq 1 ]]; then
_abort ".gitsecret folder is ignored."
fi
=======
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
# Checking gpg setup:
local secring="$SECRETS_DIR_KEYS/secring.gpg"
if [[ -f $secring ]] && [[ -s $secring ]]; then
@ -22,6 +25,7 @@ function _check_setup {
}
<<<<<<< HEAD
function _incorrect_usage {
echo "$1"
usage
@ -29,12 +33,18 @@ function _incorrect_usage {
}
=======
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
function _init_script {
# checking for proper set-up:
_check_setup
if [[ $# == 0 ]]; then
<<<<<<< HEAD
_incorrect_usage "no input parameters provided." 126
=======
usage "no input parameters provided."
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
fi
# load dependencies:
@ -44,7 +54,11 @@ function _init_script {
if [[ $(_function_exists "$1") == 0 ]] && [[ ! $1 == _* ]]; then
$1 "${@:2}"
else
<<<<<<< HEAD
_incorrect_usage "command $1 not found." 126
=======
usage "command $1 not found."
>>>>>>> 9d38280603b2b61d2ec991a031c0e776adde6f18
fi
}

Loading…
Cancel
Save