Skip to content

Commit

Permalink
added argument-documentation to rustup-init.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
aarthiJ committed Feb 25, 2017
1 parent 408ed84 commit b1a1ff5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
57 changes: 43 additions & 14 deletions rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ set -u

RUSTUP_UPDATE_ROOT="https://static.rust-lang.org/rustup/dist"

#XXX: If you change anything here, please make the same changes in setup_mode.rs
usage() {
cat 1>&2 <<EOF
rustup-init 1.0.0 (408ed84 2017-02-11)
The installer for rustup
USAGE:
rustup-init [FLAGS] [OPTIONS]
FLAGS:
-v, --verbose Enable verbose output
-y Disable confirmation prompt.
--no-modify-path Don't configure the PATH environment variable
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--default-host <default-host> Choose a default host triple
--default-toolchain <default-toolchain> Choose a default toolchain to install
EOF
}

main() {
need_cmd uname
need_cmd curl
Expand Down Expand Up @@ -53,6 +75,23 @@ main() {
fi
fi

# check if we have to use /dev/tty to prompt the user
local need_tty=yes
for arg in "$@"; do
case "$arg" in
-h|--help)
usage
exit 0
;;
-y)
# user wants to skip the prompt -- we don't need /dev/tty
need_tty=no
;;
*)
;;
esac
done

if $_ansi_escapes_are_valid; then
printf "\33[1minfo:\33[0m downloading installer\n" 1>&2
else
Expand All @@ -68,18 +107,6 @@ main() {
exit 1
fi

# check if we have to use /dev/tty to prompt the user
local need_tty=yes
for arg in "$@"; do
case "$arg" in
-y)
# user wants to skip the prompt -- we don't need /dev/tty
need_tty=no
;;
*)
;;
esac
done


if [ "$need_tty" = "yes" ]; then
Expand Down Expand Up @@ -146,8 +173,10 @@ get_architecture() {
local _ostype="$(uname -s)"
local _cputype="$(uname -m)"

if [ "$(uname -o)" = Android ]; then
local _ostype=Android
if [ "$_ostype" = Linux ]; then
if [ "$(uname -o)" = Android ]; then
local _ostype=Android
fi
fi

if [ "$_ostype" = Darwin -a "$_cputype" = i386 ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/rustup-cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn main() -> Result<()> {
if arg1 == Some("--self-replace") {
return self_update::self_replace();
}

// XXX: If you change anything here, please make the same changes in rustup-init.sh
let cli = App::new("rustup-init")
.version(common::version())
.about("The installer for rustup")
Expand Down

0 comments on commit b1a1ff5

Please sign in to comment.