I'm trying to construct a command with one optional and one mandatory argument and I'd like the default if the optional argument is not provided to be #2.
Why does this not work? (error: Illegal parameter number ...)
\documentclass{article}
\newcommand{\mycommand}[2][#2]{\label{#1}#2}
\begin{document}
\mycommand{mytext}
\end{document}
And what would be a way around it?
EDIT:
For clarification of my specific use case: I'm trying to define a command that passes a variable on as an option to an environment along those lines, where myenv can have options like optionone=X or optiontwo=Y so the default for the optional #1 should be optionone=#2 (not literally #2).
\newcommand{\mycommand}[2][optionone=#2]{\begin{myenv}[#1]\input{#2}\end{myenv}}
Maybe there's generally a better approach? (The environment definition I'm using is from here.)


#1to be exactly#2--- I don't think I understand the\def\my@command[#1]#2syntax, I tried:\def\my@command[#1]option=#2{\label{#1}#2}but that doesn't work ... – jan Apr 17 '19 at 10:36