# TikZ: \newcommand with optional TikZ options

I want to create a new command with some default TikZ options that you can override using an optional argument. If working as intended the code below would generate a red line between A and B, and a translucent green line with arrows between A and C. How can I accomplish this?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}

\newcommand{\relation}[3][]
{
% this needed to be modified somehow...
\path [draw, red] (#2) -- (#3);
}

\begin{tikzpicture}
\node [draw] (A) at (0, 0) {A};
\node [draw] (B) at (3, 0) {B};
\node [draw] (C) at (3, 3) {C};
\relation{A}{B}
\relation[<->, color=green!10]{A}{C}
\end{tikzpicture}

\end{document}

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  texenthusiast Jul 12 '13 at 4:56
You already have the solution. Put draw,red,#1 and it's good to go. However, it is better to use draw=red such that you can easily override it with draw=none without having the red color set for fill etc. –  percusse Jul 12 '13 at 5:25

As @TomBombadil answered in this question a way to do that is

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\newcommand{\CloudRed}[2][180]% [angle], content
{   \begin{tikzpicture}[overlay]
\node[align=center, draw,  fill=red, text=white, cloud callout, cloud puffs=17, cloud puff arc=140, callout pointer segments=3, anchor=pointer, callout relative pointer={(#1:2 cm )}, aspect=4,scale=0.5] at (-3ex,0.5ex) {#2};
\end{tikzpicture}
}

\begin{document}

\begin{itemize}
\item XY Resistive MM\Cloud{Thank you Rui}
\item Manufactured by Rui de Oliveira\Cloud[160]{Thanks again}
\item bla bla bla\Cloud[120]{Thanks yet another time}
\end{itemize}
\end{document}


The result looks like

As @percusse suggested just a little modification is needed to your code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}

\newcommand{\relation}[3][]
{
% this needed to be modified somehow...
\path [draw=red,#1] (#2) -- (#3);
}

\begin{tikzpicture}
\node [draw] (A) at (0, 0) {A};
\node [draw] (B) at (3, 0) {B};
\node [draw] (C) at (3, 3) {C};
\relation{A}{B}
\relation[<->, color=green!40!black!100]{A}{C}
\end{tikzpicture}

\end{document}


The result is

-