function shapeshift
argparse 'h/help' -- $argv
if not set -q argv[1] $argv or if set -q _flag_help
echo "Shapeshift lets you change into another root system."
echo "It is a simple tool that mounts, and chroots a partition of your choice."
echo ""
echo "Use it in the following way:"
set_color green; echo "shapeshift nvme0n1p4"; set_color normal
echo ""
echo "Here is a list of the available partitions:"
echo ""
sudo lsblk -o NAME,SIZE,MOUNTPOINTS,TYPE | awk '$4 == "part"'
end
end
我似乎无法同时获得两者,用参数调用和用 --help 调用,似乎同时开始工作。
我尝试了这段代码的几个不同版本,一旦我用 or 将两个事件链接在一起,似乎总是会破坏代码。无论我先调用哪一个,或者是否在第二个命令前面使用单独的 if 语句。似乎总是失败。
我不知道为什么,但这似乎有效:
function shapeshift
argparse 'h/help' -- $argv
# Print the available partitions if no one given
if not parameter_is_provided $argv; if set -q _flag_help
echo "Shapeshift lets you change into another root system."
echo "It is a simple tool that mounts, and chroots a partition of your choice."
echo ""
echo "Use it in the following way:"
set_color green; echo "shapeshift nvme0n1p4"; set_color normal
echo ""
echo "Here is a list of the available partitions:"
echo ""
sudo lsblk -o NAME,SIZE,MOUNTPOINTS,TYPE | awk '$4 == "part"'
return 0
end
end