Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Bash by Thanatermesis ( 15 years ago )
#!/bin/bash


main(){
   local color label

if [[ -z $2 ]] ; then
   echo -e "Usage: $(basename $0) namefile-to-create example-num"
   echo -e "examples:"
   echo -e "1) internet connections"
   echo -e "2) modx snippets/chunks"
   exit 0
fi

case $2 in 
1)
   cat > "${1}.dot" << EOF
digraph G {
   subgraph cluster_live {
      "no configuration" -> "no internet";
      "profile: default (set by default\nwhen the user set a configuration)" -> internet;
      "profile: other" -> internet;
      internet -> dhcp;
      internet -> static;
   }
}
EOF
   ;;
   2)
   cat > "${1}.dot" << EOF
digraph G {
   subgraph cluster_defines {
      label="Definitions";
      snippet [shape=diamond,style=filled,color=yellowgreen,label="Snippet"];
      chunk [shape=box,style=filled,color=gray,label="Chunk"];
      page [shape=ellipse,style=filled,color=lightblue,label="Public Page"];
      color=blue;
   }
   subgraph cluster_menu {
      label="Website";

// Pages
      node [shape=ellipse,style=filled,color=lightblue];
      PublicPage1;

// Snippets
      node [shape=diamond,style=filled,color=yellowgreen];
      snippet1;
      snippet2;

// Chunks
      node [shape=box,style=filled,color=gray];
      chunk1;
      chunk2;
      chunk3;

// Assignations
      snippet1 -> chunk1 [arrowtail=inv,arrowhead=dot];
      snippet2 -> chunk2 [arrowtail=normal,arrowhead=normal];
      snippet2 -> chunk3 [arrowtail=none,arrowhead=none];
      chunk1 -> PublicPage1;
   }
}
EOF
;;
esac


echo -e "\n${1}.dot Created."
echo -e ""
echo -e "shapes:    box, polygon, ellipse, triangle, diamond, trapezium, ellipse"
echo -e "   hexagon, octagon, doublecircle. pag. 38 ~/Documents/graphviz-dotguide.pdf"
echo -e "ex.   main -> init [style=dotted];  # linea con puntos"
echo -e "ex.   main -> init [label=\"foo\"]; # linea con frase"
echo -e "ex.   main [shape=box];  # define elemento main como caja"
echo -e "ex.   main [style=filled,color=\"red\"]; # interior pintado rojo"
echo -e ""
echo -e "Compilar:         dot -Tpng -o ${1}.png ${1}.dot"

dot -Tpng -o ${1}.png ${1}.dot

}

main "$@"

 

Revise this Paste

Your Name: Code Language: