Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. scriptname="addproject.sh";
  4.  
  5. ### FUNCTIONS ###
  6.  
  7. function show {
  8. case $1 in
  9.  
  10. "help")
  11. echo "";
  12. echo "$scriptname v1.0 – (c) 2016 Narwaro";
  13. echo "";
  14. echo "Usage: $scriptname -l <libs> [name]";
  15. echo " or: $scriptname [name]";
  16. echo ""
  17. echo "Arguments:";
  18. echo " --help or -h This help page";
  19. echo " --version or -v Version information";
  20. echo " --libs <libs> or -l <libs> Include <libs> libraries";
  21. echo "";
  22. echo " [name] Desired program name";
  23. echo "";
  24. ;;
  25.  
  26. "usage")
  27. echo "Usage: $scriptname -l <libs> [name]";
  28. echo " or: $scriptname [name]";
  29. echo "";
  30. echo "Invoke with --help for a list of available commands."
  31. echo "";
  32. ;;
  33.  
  34. "version")
  35. echo "";
  36. echo "$scriptname v1.0 - (c) 2016 Narwaro"
  37. echo "";
  38. echo "This program does not come with any warranty whatsoever"
  39. echo "and is licensed under the GNU General Public License v3";
  40. echo "You are free to modify and redistribute this software.";
  41. echo "";
  42. echo "Please report bugs to admin@narwaro.com";
  43. echo "";
  44. ;;
  45.  
  46. esac
  47.  
  48. }
  49.  
  50. function execute {
  51.  
  52. case $1 in
  53.  
  54. "main")
  55. [ $fake == true ] && echo "We're just fakin' it right now ...";
  56. echo "Creating folder named '$name'";
  57. ;;
  58.  
  59. "test")
  60. echo "Execution test. Proably something went wrong.";
  61. ;;
  62.  
  63. esac
  64.  
  65.  
  66. }
  67.  
  68. ### END FUNCTIONS ###
  69.  
  70.  
  71. case $1 in
  72.  
  73. "-h"|"--help")
  74. show help
  75. ;;
  76.  
  77. "-v"|"--version")
  78. show version
  79. ;;
  80.  
  81. "-l"|"--libs")
  82. echo "Test";
  83. ;;
  84.  
  85. "--fake")
  86. fake=true;
  87. name=$2;
  88. execute main
  89. ;;
  90.  
  91. "-"*)
  92. echo "Unknown argument / faulty invocation."
  93. echo "";
  94. show usage
  95. ;;
  96.  
  97. *)
  98. echo "Starting to create new project named '$1' ...";
  99. echo "Creating folder named '$1' ...";
  100. mkdir $1;
  101. mkdir_exit=$?;
  102. [ $mkdir_exit -ne 0 ] && echo "$scriptname: child mkdir returned non-zero exit-status ($mkdir_exit). Check permissions."; echo "Aborting ...";
  103. echo "Success!";
  104. ;;
  105.  
  106. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement