[Tex/LaTex] \leftbar color specification

colorenvironments

I'm trying to use the \leftbar feature, but I would like the document to support two different bar colors. This issue gets the color set, but only a single global color. I would like some \leftbar to be red, others to be blue. Right now I am doing this:

 % https://tex.stackexchange.com/questions/22526/regarding-the-leftbar-environment
\renewenvironment{leftbar}[1][\hsize]
{
    \def\FrameCommand
    {
        {\color{blue}\vrule width 3pt}
        \hspace{0pt}
    }
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}
}
{\endMakeFramed}

I want something like:

\leftbar{color{red}}

Any thoughts would be appreciated!

[EDIT – ADDED FINAL CODE]

\renewenvironment{leftbar}[2][\hsize]
{
    \def\FrameCommand
    {
        {\color{#2}\vrule width 3pt}
        \hspace{0pt}
    }
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}
}
{\endMakeFramed}

Then to use:

\begin{leftbar}{blue}
\end{leftbar}

Best Answer

Change

 \renewenvironment{leftbar}[1]

to

\renewenvironment{leftbar}[2]

then replace blue by #2 and you can use

\begin{leftbar}{red}