oh-my-fish/pkg/omf/cli/omf.new_from_template.fish
Bruno Pinto 20ed43983b Naming functions with omf. namespace.
Having a clear namespace `omf.` improves the readability of the code as
we clarify what is the function name and what is the namespace.
2015-08-28 18:24:56 +09:00

28 lines
729 B
Fish

function omf.new_from_template -a path github user name
for file in $path/*
if test -d $file
mkdir (basename $file)
pushd (basename $file)
omf.new_from_template $file $github $user $name
else
set -l target (begin
if test (basename $file) = "{{NAME}}.fish"
echo "$name.fish"
else
echo (basename "$file")
end
end)
sed "s/{{USER_NAME}}/$user/;s/{{GITHUB_USER}}/$github/;s/{{NAME}}/$name/" \
$file > $target
echo (omf::em)" create "(omf::off)" "(begin
if test (basename $PWD) = $name
echo ""
else
echo (basename "$PWD")"/"
end
end)$target
end
end
popd >/dev/null ^&2
end