This answer
scaling latex objects
advises to use \resizebox to scale Latex objects.
However, this approach fails when rescaling a listing in beamer:
\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]
\resizebox{\textwidth}{!}{%
\begin{lstlisting}
some -program --code "Not fitting into page"
\end{lstlisting}
}
\end{frame}
\end{document}
The error one gets is
! Argument of \lst@next has an extra }.
How to scale a listing in beamer?


lstlistinginside of a macro -- that is not possible. – Feb 13 '18 at 05:22