Author Topic: NOTES: VS Code, AutoLisp Ext, and Git  (Read 581 times)

0 Members and 1 Guest are viewing this topic.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9476
NOTES: VS Code, AutoLisp Ext, and Git
« on: January 29, 2020, 05:00:15 PM »
Today I got some time to play around with the AutoLisp extension to VS Code so I thought I'd share some of my notes. I only had enough time to read some documentation, look around a little bit, and do initial setup type stuff (I didn't test any of the "debugging/send to AutoCAD" stuff yet). ..these are also my notes for my future Tutorial(s).

***
Below is my folder structure.
Code: [Select]
projects
    |
    +---doc
    |
    +---lib
    |   |
    |   +---[PROJECT NAME]
    |       |
    |       +---src
    |
    o---tools
        |
        +---[PROJECT NAME]
            |
            +---src


To get started I made a batch script for generating a new project by adding in some basic files and some git initialization. Save the following script code as "new-autolisp-project.bat" in the TOOLS directory. 

When you double click the batch script it will:
1. Ask for a project name.
2. Create files and folders:

Code: [Select]
    |   |
    |   +---[PROJECT NAME]
    |       |
    |       +---readme.md
    |       |
    |       +---.gitignore
    |       |
    |       +---.git
    |       |
    |       +---.vscode
    |       |     |
    |       |     +---tasks.json
    |       |
    |       +---src
    |       |     |
    |       |     +---[PROJECT NAME].lsp
    |       |

Code - Bash: [Select]
  1. @echo off
  2.  
  3. set /P prjName="What is the name of the project (No spaces)?: "
  4.  
  5. :mkdir
  6. if exist %prjName%\nul goto FolderExists
  7. md %prjName%
  8. md %prjName%\\.vscode
  9. :: md %prjName%\\doc
  10. md %prjName%\\src
  11. ::
  12. :: Lisp File
  13. echo ;; File Last Updated: >> %prjName%\\src\\%prjName%.lsp
  14. echo.>> %prjName%\\src\\%prjName%.lsp
  15. echo.>> %prjName%\\src\\%prjName%.lsp
  16. echo.^(defun %prjName% ^( / *error* ERROR-LST- ^)>> %prjName%\\src\\%prjName%.lsp
  17. echo.   ^(setq>> %prjName%\\src\\%prjName%.lsp
  18. echo.     ERROR-LST->> %prjName%\\src\\%prjName%.lsp
  19. echo.     ^'^("AUTOSNAP" "OSMODE" "APERTURE" "HPSPACE" "HPASSOC">> %prjName%\\src\\%prjName%.lsp
  20. echo.       "MIRRTEXT" "AUPREC" "LUPREC" "DIMZIN" "CECOLOR" "CLAYER">> %prjName%\\src\\%prjName%.lsp
  21. echo.       "CMDECHO" "FILEDIA" "OSMODE"^)>> %prjName%\\src\\%prjName%.lsp
  22. echo.     ERROR-LST- ^(mapcar ^(function ^(lambda ^(a^) ^(list ^'setvar a ^(getvar a^)^)^)^) ERROR-LST-^)>> %prjName%\\src\\%prjName%.lsp
  23. echo.     ^)>> %prjName%\\src\\%prjName%.lsp
  24. echo.   ^(defun *error* ^(msg^)>> %prjName%\\src\\%prjName%.lsp
  25. echo.     ^(command^) ^(command^)>> %prjName%\\src\\%prjName%.lsp
  26. echo.     ^(mapcar ^'eval ERROR-LST-^)^)>> %prjName%\\src\\%prjName%.lsp
  27. echo.    ;;>> %prjName%\\src\\%prjName%.lsp
  28. echo.    ;; Begin Project Code>> %prjName%\\src\\%prjName%.lsp
  29. echo.>> %prjName%\\src\\%prjName%.lsp
  30. echo.    ;;>> %prjName%\\src\\%prjName%.lsp
  31. echo.    ;; End Project Code>> %prjName%\\src\\%prjName%.lsp
  32. echo.  ^(princ^)>> %prjName%\\src\\%prjName%.lsp
  33. echo.^)>> %prjName%\\src\\%prjName%.lsp
  34. ::
  35. :: readme.md
  36. echo.# %prjName%>> %prjName%\\readme.md
  37. echo.>> %prjName%\\readme.md
  38. echo.## BRIEF>> %prjName%\\readme.md
  39. echo.>> %prjName%\\readme.md
  40. echo.One Paragraph of project description goes here.>> %prjName%\\readme.md
  41. echo.>> %prjName%\\readme.md
  42. echo.## DESCRIPTION>> %prjName%\\readme.md
  43. echo.>> %prjName%\\readme.md
  44. echo.A detailed decription of the project goes here.>> %prjName%\\readme.md
  45. echo.>> %prjName%\\readme.md
  46. echo.### GOALS>> %prjName%\\readme.md
  47. echo.>> %prjName%\\readme.md
  48. echo.Describe any goals you tried to achieve by writing this project.>> %prjName%\\readme.md
  49. echo.>> %prjName%\\readme.md
  50. echo.## PREREQUISITES>> %prjName%\\readme.md
  51. echo.>> %prjName%\\readme.md
  52. echo.Describe any other tools/code/projects this project requires.>> %prjName%\\readme.md
  53. echo.>> %prjName%\\readme.md
  54. echo.## RUNNING>> %prjName%\\readme.md
  55. echo.>> %prjName%\\readme.md
  56. echo.Describe how to call/run this code.>> %prjName%\\readme.md
  57. echo.>> %prjName%\\readme.md
  58. echo.```>> %prjName%\\readme.md
  59. echo.example call>> %prjName%\\readme.md
  60. echo.```>> %prjName%\\readme.md
  61. echo.>> %prjName%\\readme.md
  62. echo.## AUTHOR>> %prjName%\\readme.md
  63. echo.>> %prjName%\\readme.md
  64. echo.Your name [your.name@.email.com]>> %prjName%\\readme.md
  65. echo.>> %prjName%\\readme.md
  66. echo.## ACKNOWLEDGMENTS>> %prjName%\\readme.md
  67. echo.>> %prjName%\\readme.md
  68. echo.* Hat tip to anyone whose code was used>> %prjName%\\readme.md
  69. echo.* Inspiration>> %prjName%\\readme.md
  70. echo.* etc>> %prjName%\\readme.md
  71. ::
  72. :: tasks.json
  73. echo.{>> %prjName%\\.vscode\\tasks.json
  74. echo.    "version": "2.0.0",>> %prjName%\\.vscode\\tasks.json
  75. echo.    "tasks": [>> %prjName%\\.vscode\\tasks.json
  76. echo.        {>> %prjName%\\.vscode\\tasks.json
  77. echo.            "label": "package",>> %prjName%\\.vscode\\tasks.json
  78. echo.            "type": "shell",>> %prjName%\\.vscode\\tasks.json
  79. echo.            "command": "git archive -o ..\\%prjName%_archive.zip HEAD",>> %prjName%\\.vscode\\tasks.json
  80. echo.            "group": {>> %prjName%\\.vscode\\tasks.json
  81. echo.                "kind": "build",>> %prjName%\\.vscode\\tasks.json
  82. echo.                "isDefault": true>> %prjName%\\.vscode\\tasks.json
  83. echo.            }>> %prjName%\\.vscode\\tasks.json
  84. echo.        }>> %prjName%\\.vscode\\tasks.json
  85. echo.    ]>> %prjName%\\.vscode\\tasks.json
  86. echo.}>> %prjName%\\.vscode\\tasks.json
  87. ::
  88. :: .gitignore
  89. echo.# Object files >> %prjName%\\.gitignore
  90. echo.############################## >> %prjName%\\.gitignore
  91. echo.*.o >> %prjName%\\.gitignore
  92. echo.*.ko >> %prjName%\\.gitignore
  93. echo. >> %prjName%\\.gitignore
  94. echo.# Libraries >> %prjName%\\.gitignore
  95. echo.############################## >> %prjName%\\.gitignore
  96. echo.*.com >> %prjName%\\.gitignore
  97. echo.*.lib >> %prjName%\\.gitignore
  98. echo.*.a >> %prjName%\\.gitignore
  99. echo. >> %prjName%\\.gitignore
  100. echo.# Shared objects >> %prjName%\\.gitignore
  101. echo.############################## >> %prjName%\\.gitignore
  102. echo.*.dll >> %prjName%\\.gitignore
  103. echo.*.so >> %prjName%\\.gitignore
  104. echo.*.so.* >> %prjName%\\.gitignore
  105. echo.*.dylib >> %prjName%\\.gitignore
  106. echo. >> %prjName%\\.gitignore
  107. echo.# Executables >> %prjName%\\.gitignore
  108. echo.############################## >> %prjName%\\.gitignore
  109. echo.*.exe >> %prjName%\\.gitignore
  110. echo.*.out >> %prjName%\\.gitignore
  111. echo.*.app >> %prjName%\\.gitignore
  112. echo. >> %prjName%\\.gitignore
  113. echo.# Packages >> %prjName%\\.gitignore
  114. echo.############################## >> %prjName%\\.gitignore
  115. echo.# it's better to unpack these files and commit the raw source >> %prjName%\\.gitignore
  116. echo.# git has its own built in compression methods >> %prjName%\\.gitignore
  117. echo.*.7z >> %prjName%\\.gitignore
  118. echo.*.dmg >> %prjName%\\.gitignore
  119. echo.*.gz >> %prjName%\\.gitignore
  120. echo.*.iso >> %prjName%\\.gitignore
  121. echo.*.jar >> %prjName%\\.gitignore
  122. echo.*.rar >> %prjName%\\.gitignore
  123. echo.*.tar >> %prjName%\\.gitignore
  124. echo.*.zip >> %prjName%\\.gitignore
  125. echo. >> %prjName%\\.gitignore
  126. echo.# Packing-only formats >> %prjName%\\.gitignore
  127. echo.############################## >> %prjName%\\.gitignore
  128. echo.*.iso >> %prjName%\\.gitignore
  129. echo.*.tar >> %prjName%\\.gitignore
  130. echo. >> %prjName%\\.gitignore
  131. echo.# Package management formats >> %prjName%\\.gitignore
  132. echo.############################## >> %prjName%\\.gitignore
  133. echo.*.dmg >> %prjName%\\.gitignore
  134. echo.*.xpi >> %prjName%\\.gitignore
  135. echo.*.gem >> %prjName%\\.gitignore
  136. echo.*.egg >> %prjName%\\.gitignore
  137. echo.*.deb >> %prjName%\\.gitignore
  138. echo.*.rpm >> %prjName%\\.gitignore
  139. echo. >> %prjName%\\.gitignore
  140. echo.# Logs and databases >> %prjName%\\.gitignore
  141. echo.############################## >> %prjName%\\.gitignore
  142. echo.*.log >> %prjName%\\.gitignore
  143. echo.*.sql >> %prjName%\\.gitignore
  144. echo.*.sqlite >> %prjName%\\.gitignore
  145. echo. >> %prjName%\\.gitignore
  146. echo.# OS generated files >> %prjName%\\.gitignore
  147. echo.############################## >> %prjName%\\.gitignore
  148. echo..DS_Store >> %prjName%\\.gitignore
  149. echo..DS_Store? >> %prjName%\\.gitignore
  150. echo.._* >> %prjName%\\.gitignore
  151. echo..Spotlight-V100 >> %prjName%\\.gitignore
  152. echo..Trashes >> %prjName%\\.gitignore
  153. echo.ehthumbs.db >> %prjName%\\.gitignore
  154. echo.Thumbs.db >> %prjName%\\.gitignore
  155. echo. >> %prjName%\\.gitignore
  156. echo.# Local stuff >> %prjName%\\.gitignore
  157. echo.# This section is devoted to this project >> %prjName%\\.gitignore
  158. echo.############################## >> %prjName%\\.gitignore
  159. echo..vscode/*>> %prjName%\\.gitignore
  160. echo..vscode/tasks.json>> %prjName%\\.gitignore
  161. echo.*.json>> %prjName%\\.gitignore
  162. call git init %prjName%
  163. cd %prjName%
  164. call git add .gitignore
  165. call git commit -m ".gitignore: Initial commit."
  166. call git add src\\%prjName%.lsp
  167. call git commit -m "%prjName%.lsp: Initial commit."
  168. cd ..
  169. if not exist %prjName%\nul goto FolderNotMade
  170. echo Made folder %prjName%
  171. goto end
  172.  
  173. :FolderExists
  174. echo %prjName% already exists
  175. goto end
  176.  
  177. :FolderNotMade
  178. echo %prjName% could not be made
  179.  
  180. :end
  181. pause

After you run the batch script your folder structure should look like this.

Code: [Select]
projects
    |
    ...
    |
    o---tools
    |   |
    |   +---[PROJECT NAME]
    |       |
    |       +---readme.md
    |       |
    |       +---.gitignore
    |       |
    |       +---.git
    |       |
    |       +---.vscode
    |       |     |
    |       |     +---tasks.json
    |       |
    |       +---src
    |       |     |
    |       |     +---[PROJECT NAME].lsp
    |       |


Now open VS Code and "Open Folder"

Navigate to the [PROJECT NAME] folder.

In VS Code, press Ctrl+Shift+B to create an archive of your project.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

togores

  • Mosquito
  • Posts: 7
Re: NOTES: VS Code, AutoLisp Ext, and Git
« Reply #1 on: August 02, 2020, 05:47:15 PM »
I would suggest also defining a Workspace for your project. Then you could use Open Workspace... instead of Open Folder...
It would be better as you could use a multi-root Workspace if code is stored in different folders.