| #!/bin/bash |
| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| #### CATEGORY=Device discovery |
| ### print the Fuchsia address of the current selected device |
| ## usage: fx get-device-addr [--resource|--url] |
| ## |
| ## --resource print the address in resource format (encased in [] if IPv6) |
| ## --url print the address in url format (encased in [] if IPv6 and url escaped) |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? |
| fx-config-read |
| |
| if [[ $# = 0 ]]; then |
| get-fuchsia-device-addr |
| exit 0 |
| fi |
| |
| case "$1" in |
| --resource) |
| get-device-addr-resource |
| ;; |
| --url) |
| get-device-addr-url |
| ;; |
| *) |
| fx-command-help |
| ;; |
| esac |