Add some documentation
- ID
90ca5d3- date
2023-12-18 23:23:46+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
767df24- message
Add some documentation- changed files
3 files, 6 additions, 37 deletions
Changed files
fish_functions/append_to_file_if_not_exists.fish (495) → fish_functions/append_to_file_if_not_exists.fish (569)
diff --git a/fish_functions/append_to_file_if_not_exists.fish b/fish_functions/append_to_file_if_not_exists.fish
index dd30611..b932bd8 100644
--- a/fish_functions/append_to_file_if_not_exists.fish
+++ b/fish_functions/append_to_file_if_not_exists.fish
@@ -7,11 +7,8 @@
# but it will only insert it once, and won't insert it repeatedly if you
# call the function again.
#
-function append_to_file_if_not_exists
- set target_file $argv[1]
- set line_to_append $argv[2]
-
- if not grep --quiet --fixed-strings --line-regexp "$line_to_append" "$target_file"
- echo $line_to_append >> $target_file
+function append_to_file_if_not_exists --description "Append a line to a file, but only if it's not already there" --argument-names target_file line_to_append
+ if not grep --quiet --fixed-strings --line-regexp "$line_to_append" "$target_file" 2>/dev/null
+ echo "$line_to_append" >> "$target_file"
end
end
\ No newline at end of file
fish_functions/tmpdir.fish (108) → fish_functions/tmpdir.fish (100)
diff --git a/fish_functions/tmpdir.fish b/fish_functions/tmpdir.fish
index 3067114..57fce3f 100644
--- a/fish_functions/tmpdir.fish
+++ b/fish_functions/tmpdir.fish
@@ -1,3 +1,3 @@
-function tmpdir --description "Quickly create and switch into a temporary directory"
+function tmpdir --description "Create and switch into a temporary directory"
cd (mktemp -d)
end
fish_functions/venv.fish (1534) → fish_functions/venv.fish (597)
diff --git a/fish_functions/venv.fish b/fish_functions/venv.fish
index 9ae3b10..fdb414d 100644
--- a/fish_functions/venv.fish
+++ b/fish_functions/venv.fish
@@ -3,42 +3,14 @@
# This is to prevent me from making a very common mistake, which is
# creating the venv and then immediately running "pip install" without
# activating it first.
-function venv
+function venv --description "Create and activate a new virtual environment"
echo "Creating virtual environment in "(pwd)"/.venv"
python3 -m venv .venv --upgrade-deps
+ source .venv/bin/activate.fish
# Append .venv to the Git exclude file, but only if it's not
# already there.
if test -e .git
append_to_file_if_not_exists ".git/info/exclude" ".venv"
end
-
- source .venv/bin/activate.fish
-
- # If we're in a trusted Git repository (one that I own) and we
- # can see a requirements file, go ahead and install pip-tools
- # and install the dependencies.
- if test -e .git
- set remote_url (git remote get-url origin)
-
- set -a trusted_orgs "Flickr-Foundation" "alexwlchan"
-
- for org in $trusted_orgs
- if ! string match -q -- "git@github.com:$org/*" "$remote_url"
- continue
- end
-
- echo "This repo is in in a trusted org; looking for dependencies"
-
- if test -f dev_requirements.txt
- echo "Installing dependencies from dev_requirements.txt"
- pip install -r dev_requirements.txt
- else if test -f requirements.txt
- echo "Installing dependencies from requirements.txt"
- pip install -r requirements.txt
- else
- echo "No requirements.txt file found; no dependencies installed"
- end
- end
- end
end