gar_setup_menu_do {googleAuthR}R Documentation

Setup wizard help - the functions that will execute on different menu options

Description

Setup wizard help - the functions that will execute on different menu options

Usage

gar_setup_menu_do(menu_option, trigger, do_function, stop = FALSE, ...)

Arguments

menu_option

The menu option chosen from menu or gar_setup_menu

trigger

What option will trigger the do_function

do_function

The function in the same order as the menu options

stop

Whether to stop and exit if the function comes back FALSE

...

arguments passed to do_function

Details

The functions should come back with TRUE or FALSE depending on if the setting was successful.

Value

FALSE if setting was not set, TRUE if it was

See Also

Other setup functions: gar_setup_auth_check(), gar_setup_auth_key(), gar_setup_clientid(), gar_setup_edit_renviron(), gar_setup_env_check(), gar_setup_menu()

Examples


## Not run: 

op <- gar_setup_menu(c("Check all settings",
                       "Configure authentication",
                       "Configure env arg 1",
                       "Configure env arg 2",
                       "Configure something else"
                       ),
                       package_name = "googleAuthR")
                       
choice <- gar_setup_check_session()

custom_env_check_f <- function(choice){
  r <- readline("project-id:")
  gar_setup_env_check("ARG2", 
                      set_to = r, 
                      edit_option = choice == 1, #allow editing of env arg
                      session_user = choice)
  TRUE
}

gar_setup_menu_do(op, c(1,2), my_setup_auth_f, stop = TRUE)
gar_setup_menu_do(op, c(1,3), gar_setup_env_check, 
                  env_arg = "ARG1", set_to = "BLAH", 
                  edit_option = choice == 1, #allow editing of env arg
                  session_user = choice)
gar_setup_menu_do(op, c(1,4), custom_env_check_f)
gar_setup_menu_do(op, c(1,4), my_setup_something_f)


## End(Not run)

[Package googleAuthR version 2.0.2 Index]