Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update internal API and rename sh files to bash for clarity.

  • Loading branch information...
commit 2c3f08d089cd4389f64579860f67a284c2990400 1 parent 060dc5f
@zeekay authored
View
2  bin/ellipsis
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-source "$(dirname "${BASH_SOURCE[0]}")/../src/init.sh"
+source "$(dirname "${BASH_SOURCE[0]}")/../src/init.bash"
load cli
View
7 scripts/install.sh → scripts/install.bash
@@ -24,21 +24,18 @@ FINAL_ELLIPSIS_PATH=${ELLIPSIS_PATH:-$HOME/.ellipsis}
ELLIPSIS_PATH="$tmp_dir/ellipsis"
# Initialize ellipsis.
-source $tmp_dir/ellipsis/src/init.sh
+source $tmp_dir/ellipsis/src/init.bash
# Load modules.
load ellipsis
load fs
-load git
load os
-load pkg
load registry
-load utils
ELLIPSIS_PATH="$FINAL_ELLIPSIS_PATH"
# Backup existing ~/.ellipsis if necessary and move project into place.
-ellipsis.backup $ELLIPSIS_PATH
+fs.backup $ELLIPSIS_PATH
mv $tmp_dir/ellipsis $ELLIPSIS_PATH
# Clean up (only necessary on cygwin, really).
View
4 scripts/shim.sh
@@ -1,7 +1,7 @@
EOF
-# shim for ellipsis install.sh
+# shim for ellipsis install.bash
#
# This is used on ellipsis.sh to bootstrap the full installer, which you
# otherwise can't curl and pipe to sh (as it requires bash). Not meant to be
@@ -18,7 +18,7 @@ for dep in $deps; do
done
# Download full installer and execute with bash
-curl -sL https://raw.githubusercontent.com/zeekay/ellipsis/master/scripts/install.sh > install-$$.sh
+curl -sL https://raw.githubusercontent.com/zeekay/ellipsis/master/scripts/install.bash > install-$$.sh
bash install-$$.sh
# Clean up
View
8 src/cli.sh → src/cli.bash
@@ -1,13 +1,7 @@
-#!/usr/bin/env bash
+# cli.bash
#
-# cli.sh
# Command line interface for ellipsis.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
load ellipsis
load registry
View
35 src/ellipsis.sh → src/ellipsis.bash
@@ -1,13 +1,7 @@
-#!/usr/bin/env bash
+# ellipsis.bash
#
-# ellipsis.sh
# Core ellipsis interface.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")/init.sh"
-fi
-
load fs
load git
load pkg
@@ -41,18 +35,18 @@ ellipsis.install() {
case "$1" in
http:*|https:*|git:*|ssh:*)
PKG_NAME="$(echo $1 | rev | cut -d '/' -f 1 | rev)"
- PKG_PATH="$(pkg.name_to_path $PKG_NAME)"
+ PKG_PATH="$(pkg.path_from_name $PKG_NAME)"
PKG_URL="$1"
;;
*/*)
PKG_USER=$(echo $1 | cut -d '/' -f1)
PKG_NAME=$(echo $1 | cut -d '/' -f2)
- PKG_PATH="$(pkg.name_to_path $PKG_NAME)"
+ PKG_PATH="$(pkg.path_from_name $PKG_NAME)"
PKG_URL="$ELLIPSIS_PROTO://github.com/$PKG_USER/$PKG_NAME"
;;
*)
PKG_NAME="$1"
- PKG_PATH="$(pkg.name_to_path $PKG_NAME)"
+ PKG_PATH="$(pkg.path_from_name $PKG_NAME)"
PKG_URL="$ELLIPSIS_PROTO://github.com/$ELLIPSIS_USER/$PKG_NAME"
;;
esac
@@ -81,7 +75,7 @@ ellipsis.unlink() {
}
# List installed packages.
-ellipsis.list() {
+ellipsis.installed() {
if utils.cmd_exists column; then
ellipsis.each pkg.run_hook list | column -t -s $'\t'
else
@@ -187,7 +181,7 @@ EOF
git init
git add README.md ellipsis.sh
git commit -m "Initial commit"
- echo new package created at ${path.relative_path $PKG_PATH}
+ echo new package created at ${path.relative_to_home $PKG_PATH}
}
# Edit ellipsis.sh for package, or open ellipsis dir in $EDITOR.
@@ -202,6 +196,17 @@ ellipsis.edit() {
fi
}
+# List all symlinks (slightly optimized over calling pkg.list_symlinks for each
+# package.
+ellipsis._list_symlink_mappings() {
+ for file in $(fs.list_symlinks); do
+ local link="$(readlink $file)"
+ if [[ "$link" == $ELLIPSIS_PATH* ]]; then
+ echo "$(path.relative_to_packages $link) -> $(path.relative_to_home $file)";
+ fi
+ done
+}
+
# List all symlinks, or just symlinks for a given package
ellipsis.symlinks() {
if [ $# -eq 1 ]; then
@@ -210,9 +215,9 @@ ellipsis.symlinks() {
pkg.del
else
if utils.cmd_exists column; then
- ellipsis.list_symlink_mappings | sort | column -t
+ ellipsis._list_symlink_mappings | sort | column -t
else
- ellipsis.list_symlink_mappings | sort
+ ellipsis._list_symlink_mappings | sort
fi
fi
}
@@ -220,7 +225,7 @@ ellipsis.symlinks() {
# List broken symlinks in ELLIPSIS_HOME
ellipsis.broken() {
for file in $(find -L $ELLIPSIS_HOME -maxdepth 1 -type l); do
- echo "$(utils.strip_packages_dir $(readlink $file)) -> $(path.relative_path $file)";
+ echo "$(path.relative_to_packages $(readlink $file)) -> $(path.relative_to_home $file)";
done
}
View
20 src/fs.sh → src/fs.bash
@@ -1,13 +1,7 @@
-#!/usr/bin/env bash
+# fs.bash
#
-# fs.sh
# Files/path functions used by ellipis.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
# return true if folder is empty
fs.folder_empty() {
if [ "$(find $1 -prune -empty)" ]; then
@@ -45,18 +39,6 @@ fs.list_symlinks() {
find "${1:-$ELLIPSIS_HOME}" -maxdepth 1 -type l
}
-# List all symlinks (slightly optimized over calling pkg.list_symlinks for each
-# package.
-# List all symlinks and files they resolve to
-fs.list_symlink_mappings() {
- for file in $(fs.list_symlinks); do
- local link="$(readlink $file)"
- if [[ "$link" == $ELLIPSIS_PATH* ]]; then
- echo "$(utils.strip_packages_dir $link) -> $(path.relative_path $file)";
- fi
- done
-}
-
# backup existing file, ensuring you don't overwrite existing backups
fs.backup() {
local original="$1"
View
8 src/git.sh → src/git.bash
@@ -1,15 +1,11 @@
-#!/usr/bin/env bash
+# git.bash
#
-# git.sh
# Assorted git utility functions. These functions all require us to cd into the
# git repo we want to operate on first. These exist mostly for aesthetic
# reasons, i.e., pretty output in the various ellipsis commands and can be used
# by package authors for consistency with them.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
+load pkg
# Clone a Git repo.
git.clone() {
View
8 src/github.sh → src/github.bash
@@ -1,14 +1,8 @@
-#!/usr/bin/env bash
+# github.bash
#
-# github.sh
# Assorted functions for querying Github for package information and formatting
# responses.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
# Search epmi org on Github for a given package.
github.search() {
curl -s https://api.github.com/search/repositories\?q\=$1+user:epmi+fork:only
View
22 src/hooks.sh → src/hooks.bash
@@ -1,13 +1,7 @@
-#!/usr/bin/env bash
+# hooks.bash
#
-# hooks.sh
# Default hooks used by ellipsis when package hooks are undefined.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
load fs
load pkg
load utils
@@ -26,7 +20,7 @@ hooks.unlink() {
# Remove package's symlinks then remove package.
hooks.uninstall() {
- pkg.run_hook pkg.unlink
+ pkg.run_hook unlink
rm -rf $PKG_PATH
}
@@ -35,28 +29,28 @@ hooks.symlinks() {
echo -e "\033[1m$PKG_NAME\033[0m"
if utils.cmd_exists column; then
- pkg.symlinks_mappings | sort | column -t
+ pkg.list_symlink_mappings | sort | column -t
else
- pkg.symlinks_mappings | sort
+ pkg.list_symlink_mappings | sort
fi
}
# Do git pull from package
hooks.pull() {
- pkg.run git.pull
+ git.pull
}
# Do git push from package
hooks.push() {
- pkg.run git.push
+ git.push
}
# List repo status.
hooks.list() {
- pkg.run git.list
+ git.list
}
# List repo status if it's changed and show git diffstat.
hooks.status() {
- pkg.run git.status
+ git.status
}
View
13 src/init.sh → src/init.bash
@@ -1,13 +1,10 @@
-#!/usr/bin/env bash
+# init.bash
#
-# init.sh
-# Setup initial globals and load function used to source other modules.
+# Setup initial globals and load function used to source other modules. This
+# file must be sourced before any others.
-# These globals can be set by a user to use a custom ellipsis fork/set of packages/etc
-
-# git config returns 1 if key isn't found, so we pipe to cat to squash that in
-# the case it's not-defined.
if [[ -z "$ELLIPSIS_USER" ]]; then
+ # Pipe to cat to squash git config's exit code 1 in case of missing key.
GITHUB_USER=$(git config github.user | cat)
ELLIPSIS_USER=${GITHUB_USER:-zeekay}
fi
@@ -36,7 +33,7 @@ load() {
# Mark this module as loaded, prevent infinite recursion, ya know...
eval "$loaded=1"
- source $ELLIPSIS_PATH/src/$1.sh
+ source $ELLIPSIS_PATH/src/$1.bash
fi
}
View
3  src/log.sh → src/log.bash
@@ -1,6 +1,5 @@
-#!/usr/bin/env bash
+# log.bash
#
-# log.sh
# Logging utilities.
log.info() {
View
4 src/os.sh → src/os.bash
@@ -1,9 +1,7 @@
-#!/usr/bin/env bash
+# os.bash
#
-# os.sh
# Platform detection and OS functions.
-# platform detection
os.platform() {
case "$(uname | tr '[:upper:]' '[:lower:]')" in
cygwin*)
View
22 src/path.sh → src/path.bash
@@ -1,13 +1,7 @@
-#!/usr/bin/env bash
+# path.bash
#
-# path.sh
# Pathname functions used by ellipis.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
# dunno how this isn't part of POSIX
path.abs_path() {
echo $(cd $(dirname "$1"); pwd)/$(basename "$1")
@@ -26,21 +20,11 @@ path.is_path() {
}
# return path to file relative to HOME (if possible)
-path.relative_path() {
+path.relative_to_home() {
echo ${1/$HOME/\~}
}
# Path relative to packagesreturn path to file in packages dir
-path.relative_packages_path() {
+path.relative_to_packages() {
echo ${1/$ELLIPSIS_PATH\/packages\//}
}
-
-# Convert package name to path.
-path.pkg_path_from_name() {
- echo "$ELLIPSIS_PATH/packages/$1"
-}
-
-# Convert package path to name, stripping any leading dots.
-path.pkg_name_from_path() {
- echo ${1##*/} | sed -e "s/^\.//"
-}
View
28 src/pkg.sh → src/pkg.bash
@@ -1,14 +1,8 @@
-#!/usr/bin/env bash
+# pkg.bash
#
-# pkg.sh
# Ellipsis package interface. Encapsulates various useful functions for working
# with packages.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
load fs
load hooks
load log
@@ -18,15 +12,25 @@ load utils
# List of hooks available to package authors.
PKG_HOOKS=(install uninstall unlink symlinks pull push status list)
+# Convert package name to path.
+pkg.path_from_name() {
+ echo "$ELLIPSIS_PATH/packages/$1"
+}
+
+# Convert package path to name, stripping any leading dots.
+pkg.name_from_path() {
+ echo ${1##*/} | sed -e "s/^\.//"
+}
+
# Set PKG_NAME, PKG_PATH. If $1 looks like a path it's assumed to be
# PKG_PATH and not PKG_NAME, otherwise assume PKG_NAME.
pkg.init_globals() {
if path.is_path "$1"; then
PKG_PATH="$1"
- PKG_NAME="$(path.pkg_name_from_path $PKG_PATH)"
+ PKG_NAME="$(pkg.name_from_path $PKG_PATH)"
else
PKG_NAME="$1"
- PKG_PATH="$(path.pkg_path_from_name $PKG_NAME)"
+ PKG_PATH="$(pkg.path_from_name $PKG_NAME)"
fi
}
@@ -56,7 +60,7 @@ pkg.list_symlinks() {
}
# Print file -> symlink mapping
-pkg.symlinks_mappings() {
+pkg.list_symlink_mappings() {
for file in $(fs.list_symlinks); do
local link=$(readlink $file)
@@ -89,9 +93,9 @@ pkg.run_hook() {
# Run packages's hook.
if utils.cmd_exists pkg.$1; then
- run pkg.$1
+ pkg.run pkg.$1
else
- run hooks.$1
+ pkg.run hooks.$1
fi
}
View
9 src/registry.sh → src/registry.bash
@@ -1,14 +1,7 @@
-#!/usr/bin/env bash
+# registry.bash
#
-# registry.sh
# Interface to ellipsis package manager index. Uses github under the covers.
-# Initialize ourselves if we haven't yet.
-if [[ $ELLIPSIS_INIT -ne 1 ]]; then
- source "$(dirname "${BASH_SOURCE[0]}")"/init.sh
-fi
-
-# Load deps.
load github
# Search registry for ellipsis packages.
View
3  src/utils.sh → src/utils.bash
@@ -1,6 +1,5 @@
-#!/usr/bin/env bash
+# utils.bash
#
-# utils.sh
# Utility functions used by ellipsis.
# check if a command or function exists
View
0  src/version.sh → src/version.bash
File renamed without changes
View
2  test/_helper.bash
@@ -7,7 +7,7 @@ export TESTS_DIR="$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)"
export PATH="$TESTS_DIR/../bin:$PATH"
# Initialize ellipsis, which replaces bat's `load` function with ours.
-source $TESTS_DIR/../src/init.sh
+load ../src/init
# Install ourselves for Travis CI
if [ "$TRAVIS" ] && [ ! -e "/home/travis/.ellipsis" ]; then
View
16 test/path.bats
@@ -12,19 +12,11 @@ teardown() {
rm -rf $ELLIPSIS_HOME
}
-@test "path.pkg_name_from_path should derive package name from package path" {
- skip
-}
-
-@test "path.pkg_path_from_name should derive package path from package name" {
- skip
-}
-
-@test "path.relative_path should print relative path to file" {
- run path.relative_path $HOME/.ellipsis
+@test "path.relative_to_home should print path relative to $HOME" {
+ run path.relative_to_home $HOME/.ellipsis
[ "$output" = "~/.ellipsis" ]
- run path.relative_path ~/.ellipsis
+ run path.relative_to_home ~/.ellipsis
[ "$output" = "~/.ellipsis" ]
- run path.relative_path tmp
+ run path.relative_to_home tmp
[ "$output" = "tmp" ]
}
View
8 test/pkg.bats
@@ -12,6 +12,14 @@ teardown() {
rm -rf $ELLIPSIS_HOME
}
+@test "pkg.name_from_path should derive package name from package path" {
+ skip
+}
+
+@test "pkg.path_from_name should derive package path from package name" {
+ skip
+}
+
@test "pkg.init_globals should setup PKG_PATH and PKG_NAME properly" {
skip
}
Please sign in to comment.
Something went wrong with that request. Please try again.