# How do I draw a vertical line beside an item in enumerate

I would like to draw some (colored) vertical lines along side an item in the enumerate environment like the following does. The problem is that what I do is really hacky. Rather than having a bunch of items within a single enumerate, I make a minipage for each item, and put an enumerate inside that minipage. My attempts to "factor out" the enumerate results in the \vrule being badly positioned and I'm having trouble controlling the width of the item.

This looks like what I want, but it's awkward and I'd really like a better way to handle it.

\documentclass{article}
\usepackage{enumitem}
\usepackage{color}
\usepackage{lipsum}
\begin{document}

\lipsum[1]

\smallskip

\noindent\textcolor{red}{\vrule width 4pt}
\begin{minipage}{\dimexpr\textwidth-2\fboxsep}
\begin{enumerate}[labelwidth=1.5cm,labelindent=10pt,leftmargin=0.5\leftmargin]
\setcounter{enumi}{0}
\item \lipsum[2]
\end{enumerate}
\end{minipage}
\smallskip

\noindent\textcolor{blue}{\vrule width 4pt}
\begin{minipage}{\dimexpr\textwidth-2\fboxsep}
\begin{enumerate}[labelwidth=1.5cm,labelindent=10pt,leftmargin = 0.5\leftmargin]
\setcounter{enumi}{1}%not clear to me why resume didn't work
\item \lipsum[3]
\end{enumerate}
\end{minipage}

\smallskip

\lipsum[4]
\end{document}


I would like to have a solution that is as simple as this one which simply puts an asterisk before the number. I would expect that something similar would allow

\begin{enumerate}
\item \mycommand{color} \begin{minipage}{some width} text \end{minipage}
\item \mycommand{newcolor} ...
\end{enumerate}


This works by putting the item into a savebox, measuring its size and overlaying the colored line on top.

The spacing between items is larger than the OP, as one would expect (see A list and a figure side by side)

I had the hardest time getting this to work. I believe that \item is incompatible with \rlap, \llap and \sbox0.

\documentclass{article}
\usepackage{enumitem}
\usepackage{color}
\usepackage{lipsum}
\begin{document}

\newsavebox{\tempbox}

\newcommand{\coloritem}[2]% #1 = color of bar, #2 = item text
{\item \savebox{\tempbox}{\parbox[t]{\linewidth}{#2}}%
\usebox{\tempbox}\hspace{-\columnwidth}%
{\color{#1}\rule[-\dp\tempbox]{4pt}{\dimexpr \ht\tempbox+\dp\tempbox}}%
}

\lipsum[1]

\smallskip

\begin{enumerate}
\coloritem{red}{\lipsum[2]}
\coloritem{blue}{\lipsum[3]}
\end{enumerate}

\smallskip

\lipsum[4]
\end{document}