Getting the name of a piped in argument

I am trying to get the name of an argument that is passed into a function, and noticed the behavior changes depending on whether the argument is piped in or not.

library(tidyverse)

show_name <- function(data){
  substitute(data) %>% 
    deparse()
}

show_name(mpg)
#> [1] "mpg"

mpg %>% 
  show_name()
#> [1] "."

This allow happens with an rlang approach.

library(tidyverse)
library(rlang)

show_name <- function(data){
  as_name(enquo(data))
}

show_name(mpg)
#> [1] "mpg"

mpg %>% 
  show_name()
#> [1] "."

Is there a way to make this behavior consistent when piping in an argument.

Created on 2020-10-09 by the reprex package (v0.3.0)

Created on 2020-10-09 by the reprex package (v0.3.0)

Sorry, it looks like this was answered in this post. You can use sys.calls() to access the full function call.