[fx] validate `fx use` arg
Now `fx use` will check that there exists an `args.gn` in the directory
indicated.
Change-Id: I96194fdf2040d2c0cfa81c9d62256f596d3a090f
diff --git a/devshell/use b/devshell/use
index 9c7bbc7..429743d 100755
--- a/devshell/use
+++ b/devshell/use
@@ -23,7 +23,20 @@
local -r build_dir="$1"
- fx-config-write "${build_dir}"
+ if [[ "$build_dir" == /* ]]; then
+ local -r full_build_dir="${build_dir}"
+ else
+ local -r full_build_dir="${FUCHSIA_DIR}/${build_dir}"
+ fi
+
+ if [[ -e "${full_build_dir}/args.gn" ]]; then
+ fx-config-write "${build_dir}"
+ else
+ echo "\"${build_dir}\" is not a valid build dir."
+ echo ""
+ fx-command-help
+ return 1
+ fi
}
main "$@"