I'm creating a command to generate a series of macros all with equivalent styling. i.e. something along the lines of [1](https://tex.stackexchange.com/a/217763/54688)

```
\newcommand{\newcustommacro}[2]{\newcommand{#1}[1][Default]{#2{##1}}}
\newcustommacro{\macroA}{\textbf}

```

Now, I want my macro to have [Special behavior if optional argument is not passed](https://tex.stackexchange.com/a/217763/54688) so I'm using David Carlisle's answer from that question. 

However, when that `\newcommand` method is nested inside another `\newcommand` then it stops working.

```
\documentclass{standalone}

\makeatletter
\newcommand{\testA}[1][\@nil]{
  \def\tmp{#1}%
  \ifx\tmp\@nnil%
    No arg: Hello%
  \else
    Yes arg: Bye(#1)%
  \fi
}
\makeatother

\newcommand{\makeamacro}[2]{%
  \makeatletter
  \newcommand{#1}[1][\@nil]{
    \def\tmp{##1}%
    \ifx\tmp\@nnil%
      No arg: Hello%
    \else
      Yes arg: #2(##1)
    \fi
  }
  \makeatother
}

\makeamacro{\testB}{Bye}

\begin{document}

  testA, no arg: \testA

  testA, yes arg: \testA[arg]

  testB, no arg: \testB

  testB, yes arg: \testB[arg]

\end{document}

```

[![Output](https://i.stack.imgur.com/9qLJ3.png)](https://i.stack.imgur.com/9qLJ3.png)

I doubled the #'s as required for passing arguments to nested newcommands. What do I need to do for the @'s? I'm stumped.

I have no averstion to `xparse` so if someone suggests a nested verison of [egreg's answer](https://tex.stackexchange.com/a/217764/54688) to the same question linked above then that'd be ok too.

---

[1](https://tex.stackexchange.com/a/217763/54688): I know the example is just making a macro that is basically just `\textbf{}`