Skip to content
Snippets Groups Projects
Commit 7fefaa5c authored by Eduardo E. R. Junior's avatar Eduardo E. R. Junior
Browse files

Corrige bugs e padroniza mensagens ao usuário

parent 9772e005
Branches
No related tags found
1 merge request!1Issue#1
...@@ -25,7 +25,9 @@ $* ...@@ -25,7 +25,9 @@ $*
executa a função runApp, abrindo o navegador padrão executa a função runApp, abrindo o navegador padrão
-t : cria os arquivos conforme template definido para -t : cria os arquivos conforme template definido para
o projeto IGUIR2 o projeto IGUIR2. Obs.: Tenha em um diretório acima da
aplicação (cd ..) o arquivo template.R com função R
chamada template já definida.
run: Executa uma aplicação shiny, com função runApp run: Executa uma aplicação shiny, com função runApp
...@@ -52,7 +54,7 @@ build_App() { ...@@ -52,7 +54,7 @@ build_App() {
echo -n " Deseja sobrescrever? " echo -n " Deseja sobrescrever? "
read ANSWER read ANSWER
case "$ANSWER" in case "$ANSWER" in
s | sim | y | yes) echo "-------------------------------------------";; s | sim | y | yes) echo "";;
n | não | no) exit 1;; n | não | no) exit 1;;
* ) echo " Responda com as palavres: yes ou no" * ) echo " Responda com as palavres: yes ou no"
exit 1 exit 1
...@@ -88,6 +90,7 @@ build_App() { ...@@ -88,6 +90,7 @@ build_App() {
run) run)
echo "Criando ui.R e server.R em $DIR" echo "Criando ui.R e server.R em $DIR"
emacs server.R ui.R & emacs server.R ui.R &
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)" Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
;; ;;
*) *)
...@@ -101,12 +104,16 @@ build_AppTemplate() { ...@@ -101,12 +104,16 @@ build_AppTemplate() {
echo -n " Deseja sobrescrever? " echo -n " Deseja sobrescrever? "
read ANSWER read ANSWER
case "$ANSWER" in case "$ANSWER" in
s | sim | y | yes) echo "-------------------------------------------";; s | sim | y | yes) echo "";;
n | não | no) exit 1;; n | não | no) exit 1;;
* ) echo " Responda com as palavres: yes ou no" * ) echo " Responda com as palavres: yes ou no"
exit 1 exit 1
esac esac
fi fi
if [ ! -e "../template.R" ]; then
echo "Arquivo template.R não existe! Favor defini-lo no diretório acima."
exit 1
fi
##------------------------------------------- ##-------------------------------------------
# Criando o server.R # Criando o server.R
echo "##-------------------------------------------" > server.R echo "##-------------------------------------------" > server.R
...@@ -137,7 +144,7 @@ build_AppTemplate() { ...@@ -137,7 +144,7 @@ build_AppTemplate() {
echo "shinyUI(" >> ui.R echo "shinyUI(" >> ui.R
echo " fluidPage(" >> ui.R echo " fluidPage(" >> ui.R
echo " ## Cabeçalho IGUIR2" >> ui.R echo " ## Cabeçalho IGUIR2" >> ui.R
echo " htmlOutput(\"header\")," >> ui.R echo " htmlOutput(\"header\")" >> ui.R
echo " " >> ui.R echo " " >> ui.R
echo " " >> ui.R echo " " >> ui.R
echo " )" >> ui.R echo " )" >> ui.R
...@@ -148,6 +155,7 @@ build_AppTemplate() { ...@@ -148,6 +155,7 @@ build_AppTemplate() {
run) run)
echo "Criando ui.R e server.R em $DIR" echo "Criando ui.R e server.R em $DIR"
emacs server.R ui.R & emacs server.R ui.R &
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)" Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
;; ;;
*) *)
...@@ -165,7 +173,10 @@ fi ...@@ -165,7 +173,10 @@ fi
# secundários, init e run. getopts é MUITO MUItO útil para opções do # secundários, init e run. getopts é MUITO MUItO útil para opções do
# tipo -* # tipo -*
## Aplicação ##======================================================================
## Inicia o script
echo "-------------------------------------------"
if [ $1 = "init" ]; then if [ $1 = "init" ]; then
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
build_App build_App
...@@ -193,6 +204,7 @@ if [ $1 = "init" ]; then ...@@ -193,6 +204,7 @@ if [ $1 = "init" ]; then
elif [ $1 = "run" ]; then elif [ $1 = "run" ]; then
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
echo "Executando a aplicação em $DIR" echo "Executando a aplicação em $DIR"
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)" Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
elif [ $# -eq 2 ]; then elif [ $# -eq 2 ]; then
case $2 in case $2 in
...@@ -201,12 +213,20 @@ elif [ $1 = "run" ]; then ...@@ -201,12 +213,20 @@ elif [ $1 = "run" ]; then
-o ) -o )
echo "Executando a aplicação e abrir arquivos no emacs" echo "Executando a aplicação e abrir arquivos no emacs"
emacs server.R ui.R & emacs server.R ui.R &
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)" Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
;; ;;
*) *)
if [ -d $2 ]; then if [ -d $2 ]; then
echo "Rodar a aplicação em $2" cd $2
Rscript -e "shiny::runApp(\"$2\", launch.browser = TRUE)" if [ ! -e "$SV" ] || [ ! -e "$UI" ]; then
echo "Este diretório não contém uma aplicação shiny completa"
echo "Verifique os arquivos server.R e ui.R em $2"
exit 1
fi
echo "Executando a aplicação em $2"
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
else else
echo "Argumentos inválidos! Consulte shinyApp --help" echo "Argumentos inválidos! Consulte shinyApp --help"
exit 1 exit 1
...@@ -222,16 +242,18 @@ elif [ $1 = "run" ]; then ...@@ -222,16 +242,18 @@ elif [ $1 = "run" ]; then
exit 1 exit 1
fi fi
emacs server.R ui.R & emacs server.R ui.R &
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)" Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
elif [ $3 = "-o" ] && [ -d $2 ]; then elif [ -d $2 ] && [ $3 = "-o" ]; then
echo "Executando a aplicação em $2" echo "Executando a aplicação em $2"
cd $2 cd $2
if [ ! -e "$SV" ] || [ ! -e "$UI" ]; then if [ ! -e "$SV" ] || [ ! -e "$UI" ]; then
echo "Este diretório não contém uma aplicação shiny completa" echo "Este diretório não contém uma aplicação shiny completa"
echo "Verifique os arquivos server.R e ui.R em $3" echo "Verifique os arquivos server.R e ui.R em $2"
exit 1 exit 1
fi fi
emacs server.R ui.R & emacs server.R ui.R &
echo "Pressione ^C para interromper a aplicação"
Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)" Rscript -e "shiny::runApp(getwd(), launch.browser = TRUE)"
else else
echo "Argumentos inválidos! Consulte shinyApp --help" echo "Argumentos inválidos! Consulte shinyApp --help"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment