Commit 158407151359c11692021103dac66626a851aded

Authored by Shrikant Sharat
1 parent aa510273db

Refactoring of private functions.

Private functions should all be prefixed with `-bundle-`.

Showing 1 changed file with 17 additions and 18 deletions Side-by-side Diff

... ... @@ -50,13 +50,20 @@ bundle () {
50 50 # Add it to the record.
51 51 _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype"
52 52  
53   - -antigen-ensure-repo "$url"
  53 + -bundle-ensure-repo "$url"
54 54  
55   - bundle-load "$url" "$loc" "$btype"
  55 + -bundle-load "$url" "$loc" "$btype"
56 56  
57 57 }
58 58  
59   --antigen-get-clone-dir () {
  59 +bundle-update () {
  60 + # Update your bundles, i.e., `git pull` in all the plugin repos.
  61 + -bundle-echo-record | awk '{print $1}' | sort -u | while read url; do
  62 + -bundle-ensure-repo --update "$url"
  63 + done
  64 +}
  65 +
  66 +-bundle-get-clone-dir () {
60 67 # Takes a repo url and gives out the path that this url needs to be cloned
61 68 # to. Doesn't actually clone anything.
62 69 # TODO: Memoize?
... ... @@ -67,7 +74,7 @@ bundle () {
67 74 -e 's.:.-COLON-.g'
68 75 }
69 76  
70   --antigen-get-clone-url () {
  77 +-bundle-get-clone-url () {
71 78 # Takes a repo's clone dir and gives out the repo's original url that was
72 79 # used to create the given directory path.
73 80 # TODO: Memoize?
... ... @@ -78,7 +85,7 @@ bundle () {
78 85 -e 's.-COLON-.:.g'
79 86 }
80 87  
81   --antigen-ensure-repo () {
  88 +-bundle-ensure-repo () {
82 89  
83 90 local update=false
84 91 if [[ $1 == --update ]]; then
... ... @@ -87,7 +94,7 @@ bundle () {
87 94 fi
88 95  
89 96 local url="$1"
90   - local clone_dir="$(-antigen-get-clone-dir $url)"
  97 + local clone_dir="$(-bundle-get-clone-dir $url)"
91 98  
92 99 if [[ ! -d $clone_dir ]]; then
93 100 git clone "$url" "$clone_dir"
... ... @@ -97,17 +104,10 @@ bundle () {
97 104  
98 105 }
99 106  
100   -bundle-update () {
101   - # Update your bundles, i.e., `git pull` in all the plugin repos.
102   - -bundle-echo-record | awk '{print $1}' | sort -u | while read url; do
103   - -antigen-ensure-repo --update "$url"
104   - done
105   -}
106   -
107   -bundle-load () {
  107 +-bundle-load () {
108 108  
109 109 local url="$1"
110   - local location="$(-antigen-get-clone-dir "$url")/$2"
  110 + local location="$(-bundle-get-clone-dir "$url")/$2"
111 111 local btype="$3"
112 112  
113 113 if [[ $btype == theme ]]; then
... ... @@ -149,7 +149,7 @@ bundle-cleanup () {
149 149 local unused_clones="$(comm -13 \
150 150 <(-bundle-echo-record | awk '{print $1}' | sort -u) \
151 151 <(ls "$ADOTDIR/repos" | while read line; do
152   - -antigen-get-clone-url "$line"
  152 + -bundle-get-clone-url "$line"
153 153 done))"
154 154  
155 155 if [[ -z $unused_clones ]]; then
... ... @@ -166,7 +166,7 @@ bundle-cleanup () {
166 166 echo
167 167 echo "$unused_clones" | while read url; do
168 168 echo -n "Deleting clone for $url..."
169   - rm -rf "$(-antigen-get-clone-dir $url)"
  169 + rm -rf "$(-bundle-get-clone-dir $url)"
170 170 echo ' done.'
171 171 done
172 172 else
... ... @@ -180,7 +180,6 @@ bundle-lib () {
180 180 }
181 181  
182 182 bundle-theme () {
183   - local url="$ANTIGEN_DEFAULT_REPO_URL"
184 183 local name="${1:-robbyrussell}"
185 184 bundle --loc=themes/$name.zsh-theme --btype=theme
186 185 }