Skip to content

Commit

Permalink
Improved the utility
Browse files Browse the repository at this point in the history
Added localized executables
Added consistent error codes
Added the '-P', '-v' and '-V' launch arguments
Improved the help text
Cleaned the code a bit
  • Loading branch information
aziascreations committed Jun 27, 2021
1 parent 0d899fd commit 3afcd52
Show file tree
Hide file tree
Showing 7 changed files with 501 additions and 204 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.cfg
*.exe
*.txt
*.lnk
11 changes: 11 additions & 0 deletions Build/COMPILED_EXECUTABLED_WILL_BE_PUT_IN_HERE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠿⢿⣿⣿⠿⠛⠿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⠉⠄⣀⡤⢤⣤⣈⠁⣠⡔⠶⣾⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡿⠛⠋⠁⠄⠄⠄⣼⣿⠁⡀⢹⣿⣷⢹⡇⠄⠎⣿⣿⣿
⣿⣿⣿⠿⠛⠉⠁⠄⠄⠄⠄⠄⠄⠄⠹⣇⣀⣡⣾⣿⡿⠉⠛⠒⠒⠋⠉⢸
⡿⠋⠁⠄⠄⢀⣤⣤⡀⠄⠄⠄⠄⠄⠄⠈⠙⠛⠛⠉⠄⠄⠄⠄⠄⠄⠄⠈
⠄⠄⠄⠄⠄⢹⣧⡈⠿⣷⣄⣀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣠⢄⣾
⠄⠄⠄⠄⠄⠈⠻⢿⣶⣌⣙⡛⠛⠿⠶⠶⠶⠶⠶⠖⣒⣒⣚⣋⡩⢱⣾⣿
⠄⠄⠄⠄⠄⠄⠄⠄⠈⠉⠛⠛⠛⠻⠿⠿⠟⠛⠛⠛⠉⢉⣥⣶⣾⣿⣿⣿
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠒⠶⣿⣿⣿⣿⣿⣿⣿⣿
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
296 changes: 154 additions & 142 deletions ListComPort.pb

Large diffs are not rendered by default.

106 changes: 84 additions & 22 deletions ListComPort.pbp
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,126 @@
<section name="data">
<explorer view="C:\ProgramData\PureBasic\Examples\" pattern="0"/>
<log show="1"/>
<lastopen date="2021-06-27 12:55" user="Herwin" host="DESKTOP-FCBVC66"/>
<lastopen date="2021-06-27 15:53" user="Herwin" host="DESKTOP-FCBVC66"/>
</section>
<section name="files">
<file name="ListComPort.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="7387104c834b3538923117eb83030e86"/>
</file>
<file name="Includes\Arguments.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="++"/>
<fingerprint md5="d11b37a645894b6ab5c9d36a6d8f2ec6"/>
</file>
<file name="Includes\SerialHelper_Win32.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="++"/>
<config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="++"/>
<fingerprint md5="41b32b0bb5bb010edeaaba0e194bbd60"/>
</file>
<file name="Includes\WinAPI_Types.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0" panelstate="++"/>
<fingerprint md5="72af2329e4d5db955c175842c1385dcc"/>
</file>
<file name="ListComPort.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="0d404bc4f7c00c74383909517efc3ec4"/>
</file>
<file name="ListComPortLocales.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="21c9a3226ac1e25541ea105b84ead6a5"/>
</file>
<file name="ListComPortErrorCodes.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
<fingerprint md5="98ffb60033f242011ff4b24a82bb0a69"/>
</file>
</section>
<section name="targets">
<target name="x64" enabled="1" default="1">
<target name="eng x64" enabled="1" default="1">
<inputfile value="ListComPort.pb"/>
<outputfile value="Build\lscom_eng_x64.exe"/>
<compiler version="PureBasic 5.70 LTS (Windows - x64)"/>
<executable value="Build\lscom_eng_x64.exe"/>
<options debug="1"/>
<temporaryexe value="source"/>
<format exe="console" cpu="0"/>
<versioninfo enable="1">
<field0 value="2.0.0.0"/>
<field1 value="2.0.0.0"/>
<field3 value="PB-ListComPort"/>
<field4 value="2.0.0"/>
<field5 value="2.0.0"/>
<field7 value="PB-ListComPort"/>
<field8 value="lscom_eng_x64.exe"/>
<field14 value="https://github.com/aziascreations/PB-ListComPort"/>
<field17 value="0409 English (United States)"/>
</versioninfo>
<constants>
<constant value="#PBListComPortLang = &quot;eng&quot;" enable="1"/>
</constants>
</target>
<target name="eng x86" enabled="1" default="0">
<inputfile value="ListComPort.pb"/>
<outputfile value="Build\lscom_eng_x86.exe"/>
<compiler version="PureBasic 5.70 LTS (Windows - x86)"/>
<executable value="Build\lscom_eng_x86.exe"/>
<options debug="1"/>
<temporaryexe value="source"/>
<format exe="console" cpu="0"/>
<versioninfo enable="1">
<field0 value="2.0.0.0"/>
<field1 value="2.0.0.0"/>
<field3 value="PB-ListComPort"/>
<field4 value="2.0.0"/>
<field5 value="2.0.0"/>
<field7 value="PB-ListComPort"/>
<field8 value="lscom_eng_x86.exe"/>
<field14 value="https://github.com/aziascreations/PB-ListComPort"/>
<field17 value="0409 English (United States)"/>
</versioninfo>
<constants>
<constant value="#PBListComPortLang = &quot;eng&quot;" enable="1"/>
</constants>
</target>
<target name="fra x64" enabled="1" default="0">
<inputfile value="ListComPort.pb"/>
<outputfile value="lscom-x64.exe"/>
<outputfile value="Build\lscom_fra_x64.exe"/>
<compiler version="PureBasic 5.70 LTS (Windows - x64)"/>
<executable value="lscom-x64.exe"/>
<executable value="Build\lscom_fra_x64.exe"/>
<options debug="1"/>
<temporaryexe value="source"/>
<format exe="console" cpu="0"/>
<versioninfo enable="1">
<field0 value="1.1.0.0"/>
<field1 value="1.1.0.0"/>
<field0 value="2.0.0.0"/>
<field1 value="2.0.0.0"/>
<field3 value="PB-ListComPort"/>
<field4 value="1.1.0"/>
<field5 value="1.1.0"/>
<field4 value="2.0.0"/>
<field5 value="2.0.0"/>
<field7 value="PB-ListComPort"/>
<field8 value="lscom-x64.exe"/>
<field8 value="lscom_fra_x64.exe"/>
<field14 value="https://github.com/aziascreations/PB-ListComPort"/>
<field17 value="040c French (Standard)"/>
</versioninfo>
<constants>
<constant value="#PBListComPortLang = &quot;fra&quot;" enable="1"/>
</constants>
</target>
<target name="x86" enabled="1" default="0">
<target name="fra x86" enabled="1" default="0">
<inputfile value="ListComPort.pb"/>
<outputfile value="lscom-x86.exe"/>
<outputfile value="Build\lscom_fra_x86.exe"/>
<compiler version="PureBasic 5.70 LTS (Windows - x86)"/>
<executable value="lscom-x86.exe"/>
<executable value="Build\lscom_fra_x86.exe"/>
<options debug="1"/>
<temporaryexe value="source"/>
<format exe="console" cpu="0"/>
<versioninfo enable="1">
<field0 value="1.1.0.0"/>
<field1 value="1.1.0.0"/>
<field0 value="2.0.0.0"/>
<field1 value="2.0.0.0"/>
<field3 value="PB-ListComPort"/>
<field4 value="1.1.0"/>
<field5 value="1.1.0"/>
<field4 value="2.0.0"/>
<field5 value="2.0.0"/>
<field7 value="PB-ListComPort"/>
<field8 value="lscom-x86.exe"/>
<field8 value="lscom_fra_x86.exe"/>
<field14 value="https://github.com/aziascreations/PB-ListComPort"/>
<field17 value="040c French (Standard)"/>
</versioninfo>
<constants>
<constant value="#PBListComPortLang = &quot;fra&quot;" enable="1"/>
</constants>
</target>
</section>
</project>
35 changes: 35 additions & 0 deletions ListComPortErrorCodes.pbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;{
; * ListComPortErrorCodes.pbi
; Version: 2.0.0
; Author: Herwin Bozet
;
; License: Unlicense (Public Domain)
;}


;- Compiler Directives

EnableExplicit


;- Error Codes

Enumeration LSCOM_ErrorCodes
#LSCOM_ErrorCode_NoError = 0

; Fatal errors (1-9)
#LSCOM_ErrorCode_NoTerminal = 1
#LSCOM_ErrorCode_NoRequiredWinApiFunction

; Internal argument parser errors (10-19)
#LSCOM_ErrorCode_ArgumentParsingFailure = 10
#LSCOM_ErrorCode_ArgumentDefinitionFailure
#LSCOM_ErrorCode_ArgumentInitFailure

; External argument errors (20-29)
#LSCOM_ErrorCode_NoPaddingValue = 20

; Application & System errors (30-39)
#LSCOM_ErrorCode_NoFriendlyNames = 30
#LSCOM_ErrorCode_NoComPorts
EndEnumeration
161 changes: 161 additions & 0 deletions ListComPortLocales.pbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
;{
; * ListComPortLocales.pbi
; Version: 2.0.0
; Author: Herwin Bozet
;
; License: Unlicense (Public Domain)
;}

;- Notes

; Please refer to the following URL for the usable language codes:
; https://github.com/sokil/php-isocodes/blob/3.0/databases/iso_639-3.json


;- Compiler Directives

EnableExplicit

CompilerIf Not Defined(PBListComPortLang, #PB_Constant)
CompilerWarning "#PBListComPortLang$ was not defined, using 'eng' as a fallback !"
#PBListComPortLang = "eng"
CompilerEndIf


;- Locales

#LSCOM_Locale_LangCode$ = #PBListComPortLang


;-> English (eng)

CompilerIf #PBListComPortLang = "eng"
#LSCOM_Locale_LangName$ = "English"

#LSCOM_Locale_HelpSection_LaunchArgs$ = "Launch arguments"
#LSCOM_Locale_HelpSection_Remarks$ = "Remarks"
#LSCOM_Locale_HelpSection_Formatting$ = "Formatting"
#LSCOM_Locale_HelpSection_ErrorCodes$ = "Error codes"

#LSCOM_Locale_HelpSection_ErrorCodes_Fatal$ = "Fatal errors"
#LSCOM_Locale_HelpSection_ErrorCodes_Internal$ = "Internal argument parser errors"
#LSCOM_Locale_HelpSection_ErrorCodes_External$ = "External argument errors"
#LSCOM_Locale_HelpSection_ErrorCodes_Application$ = "Application and system errors"

#LSCOM_Locale_Expression_NoArguments$ = "No launch arguments"
#LSCOM_Locale_Expression_RawName$ = "Raw name"
#LSCOM_Locale_Expression_DeviceName$ = "Device name"
#LSCOM_Locale_Expression_FriendlyName$ = "Friendly name"

#LSCOM_Locale_Expression_LowerCase_Or$ = "or"
#LSCOM_Locale_Expression_LowerCase_And$ = "and"

#LSCOM_Locale_ArgumentDesc_ShowAll$ = "Display the complete port's name (Equal to '-dfn')"
#LSCOM_Locale_ArgumentDesc_ShowDevice$ = "Displays the port's device name"
#LSCOM_Locale_ArgumentDesc_Divider$ = "Uses the given string or char as a separator (Can be empty string !)"
#LSCOM_Locale_ArgumentDesc_ShowFriendly$ = "Displays the port's friendly name"
#LSCOM_Locale_ArgumentDesc_Help$ = "Display this help text"
#LSCOM_Locale_ArgumentDesc_History$ = "Display ??? (Ignores -d, -f & -n )"
#LSCOM_Locale_ArgumentDesc_ShowRaw$ = "Displays the port's raw name (See remarks section)"
#LSCOM_Locale_ArgumentDesc_NoPadding$ = "Disable the automatic padding after the raw name"
#LSCOM_Locale_ArgumentDesc_NoPretty$ = "Disables the pretty printing format (Equal to -D "+#DQUOTE$+" "+#DQUOTE$+")"
#LSCOM_Locale_ArgumentDesc_Sort$ = "Sorts the port based on their raw names in an ascending order"
#LSCOM_Locale_ArgumentDesc_SortReverse$ = "Sorts the port based on their raw names in a descending order"
#LSCOM_Locale_ArgumentDesc_TabDivider$ = "Use tabs for padding between the types of names (Overrides '-D')"
#LSCOM_Locale_ArgumentDesc_Version$ = "Shows the utility's version number and other info"
#LSCOM_Locale_ArgumentDesc_VersionOnly$ = "Shows the utility's version number only (Overrides '-v')"

#LSCOM_Locale_Remark_NamePartsAndRawDefault$ = "If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used."
#LSCOM_Locale_Remark_NoPrettyPrinting$ = "If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown."
#LSCOM_Locale_Remark_NameRaw$ = "The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...)"
#LSCOM_Locale_Remark_NameDevice$ = "The 'device name' refers to a port device path. (e.g.: \Device\Serial1, ...)"
#LSCOM_Locale_Remark_NameFriendly$ = "The 'friendly name' refers to a port name as seen in the device manager. (e.g.: Communications Port, USB-SERIAL CH340, ...)"
#LSCOM_Locale_Remark_ErrorsFatal$ = "Any result returned with an error code between 1-9 and 30-39 should be considered as invalid."
#LSCOM_Locale_Remark_ErrorsNonFatal$ = "Any result returned with another error code is valid but probably not formatted properly."

#LSCOM_Locale_Error_MBTitle$ = "Fatal error !"
#LSCOM_Locale_Error_MBText$ = "Failed to open the console !"

#LSCOM_Locale_Error_WinApiMissingFunction$ = "Cannot continue without being able to use RegGetValueW() !"
#LSCOM_Locale_Error_ArgumentDefinitionFailure$ = "Failed to register argument ! (Caused by %0)"

#LSCOM_Locale_ErrorExplaination_NoTerminal$ = "The app couldn't open a console to print to it."
#LSCOM_Locale_ErrorExplaination_WinApiMissingFunction$ = "The app can't find 'RegGetValueW' in 'Advapi32.dll'."
#LSCOM_Locale_ErrorExplaination_ArgumentParsingFailure$ = "Failed to parse the launch arguments, default options will be used."
#LSCOM_Locale_ErrorExplaination_ArgumentDefinitionFailure$ = "Failed to register one or more argument, arguments will not be parsed."
#LSCOM_Locale_ErrorExplaination_ArgumentInitFailure$ = "Failed to initialize the internal argument parser, they will be entirely ignored."
#LSCOM_Locale_ErrorExplaination_NoPaddingValue$ = "No value can be found for the '-D' argument, it will be ignored."
#LSCOM_Locale_ErrorExplaination_NoFriendlyNames$ = "No friendly name could be found."
#LSCOM_Locale_ErrorExplaination_NoComPorts$ = "No COM port could be found."
CompilerEndIf


;-> French (fra)

CompilerIf #PBListComPortLang = "fra"
#LSCOM_Locale_LangName$ = "Français"

#LSCOM_Locale_HelpSection_LaunchArgs$ = "Options de lancement"
#LSCOM_Locale_HelpSection_Remarks$ = "Remarques"
#LSCOM_Locale_HelpSection_Formatting$ = "Format de sortie"
#LSCOM_Locale_HelpSection_ErrorCodes$ = "Codes d'erreur"

#LSCOM_Locale_HelpSection_ErrorCodes_Fatal$ = "Erreurs fatales"
#LSCOM_Locale_HelpSection_ErrorCodes_Internal$ = "Erreurs interne au processeur d'arguments de lancement"
#LSCOM_Locale_HelpSection_ErrorCodes_External$ = "Erreurs externes aux arguments de lancement"
#LSCOM_Locale_HelpSection_ErrorCodes_Application$ = "Erreurs liées à l'application et à l'OS"

#LSCOM_Locale_Expression_NoArguments$ = "Aucunes options de lancement"
#LSCOM_Locale_Expression_RawName$ = "Nom brut"
#LSCOM_Locale_Expression_DeviceName$ = "Nom appareil"
#LSCOM_Locale_Expression_FriendlyName$ = "Nom familier"

#LSCOM_Locale_Expression_LowerCase_Or$ = "ou"
#LSCOM_Locale_Expression_LowerCase_And$ = "et"

#LSCOM_Locale_ArgumentDesc_ShowAll$ = "Affiche le nom complet du port (Équivalent à '-dfn')"
#LSCOM_Locale_ArgumentDesc_ShowDevice$ = "Affiche le nom d'appareil du port"
#LSCOM_Locale_ArgumentDesc_Divider$ = "Utilise le texte donné comme séparateur de type de nom (Peut être vide !)"
#LSCOM_Locale_ArgumentDesc_ShowFriendly$ = "Affiche le nom familier du port."
#LSCOM_Locale_ArgumentDesc_Help$ = "Affiche ce texte d'aide"
#LSCOM_Locale_ArgumentDesc_History$ = "Affiche uniquement l'historique des ports connus"
#LSCOM_Locale_ArgumentDesc_ShowRaw$ = "Affiche le nom brut des ports (Voir la section '"+#LSCOM_Locale_HelpSection_Remarks$+"')"
#LSCOM_Locale_ArgumentDesc_NoPadding$ = "Disable the automatic padding after the raw name"
#LSCOM_Locale_ArgumentDesc_NoPretty$ = "Désactive le format d'impression propre (Équivalent à -D "+#DQUOTE$+" "+#DQUOTE$+")"
#LSCOM_Locale_ArgumentDesc_Sort$ = "Trie les ports par ordre alphabétique selon leur nom brut"
#LSCOM_Locale_ArgumentDesc_SortReverse$ = "Trie les ports par ordre alphabétique inversé selon leur nom bru"
#LSCOM_Locale_ArgumentDesc_TabDivider$ = "Utilise une tabulation comme séparateur (Ignore '-D')"
#LSCOM_Locale_ArgumentDesc_Version$ = "Affiche le numéro de version et d'autres info sur le programme"
#LSCOM_Locale_ArgumentDesc_VersionOnly$ = "Affiche uniquement le numéro de version du programme (Ignore '-v')"

#LSCOM_Locale_Remark_NamePartsAndRawDefault$ = "Si '-d' ou '-f' sont utilisés, le nom brut ne sera pas affiché tant que '-n' n'est pas aussi utilisé."
#LSCOM_Locale_Remark_NoPrettyPrinting$ = "Si '-D', '-t' ou '-p' sont utilisés, le séparateur spécial entre le nom brut et familier, ainsi que les crochets ne seront pas affichés."
#LSCOM_Locale_Remark_NameRaw$ = "Le 'nom brut' se réfère au nom du port. (ex: COM1, COM2, ...)"
#LSCOM_Locale_Remark_NameDevice$ = "Le 'nom d'appareil' se rèfère au chemin sous lequel le port peut être accédé. (ex: \Device\Serial1, ...)"
#LSCOM_Locale_Remark_NameFriendly$ = "Le 'nom familier' se féfère au nom du port visible dans le gestionnaire de pérphériques. (ex: Communications Port, USB-SERIAL CH340, ...)"
#LSCOM_Locale_Remark_ErrorsFatal$ = "Tout résultat retourné avec un code d'erreur entre 1-9 et 30-39 doit être considéré comme invalide."
#LSCOM_Locale_Remark_ErrorsNonFatal$ = "Tout résultat retourné avec un autre code d'erreur est valide mais potentiellement mal formaté."

#LSCOM_Locale_Error_MBTitle$ = "Erreur critique !"
#LSCOM_Locale_Error_MBText$ = "Impossible d'ouvrir un invité de commande !"

#LSCOM_Locale_Error_WinApiMissingFunction$ = "Impossible de continuer sans accès à RegGetValueW() !"
#LSCOM_Locale_Error_ArgumentDefinitionFailure$ = "Échec d'enregistrement d'argument de lancement ! (Causé par %0)"

#LSCOM_Locale_ErrorExplaination_NoTerminal$ = "Le programme n'a pas réussi à avoir accès à un invité de commande."
#LSCOM_Locale_ErrorExplaination_WinApiMissingFunction$ = "Le programme ne peut pas trouver la fonction 'RegGetValueW' dans 'Advapi32.dll'."
#LSCOM_Locale_ErrorExplaination_ArgumentParsingFailure$ = "Erreur de lecture des arguments de lancement, ils seront ignorés."
#LSCOM_Locale_ErrorExplaination_ArgumentDefinitionFailure$ = "Erreur de définition des arguments de lancement, ils seront ignorés."
#LSCOM_Locale_ErrorExplaination_ArgumentInitFailure$ = "Erreur d'initialisation du lecteur arguments de lancement, ils seront ignorés."
#LSCOM_Locale_ErrorExplaination_NoPaddingValue$ = "Aucune valeur n'existe pour l'argument '-D', il sera ignoré."
#LSCOM_Locale_ErrorExplaination_NoFriendlyNames$ = "Aucun nom familier n'a pu être trouvé."
#LSCOM_Locale_ErrorExplaination_NoComPorts$ = "Aucun port COM n'a pu être trouvé."
CompilerEndIf


;-> Commons

#LSCOM_Locale_HelpSectionFormatted_ErrorCodes_Fatal$ = " * "+#LSCOM_Locale_HelpSection_ErrorCodes_Fatal$+" (1-9):"
#LSCOM_Locale_HelpSectionFormatted_ErrorCodes_Internal$ = " * "+#LSCOM_Locale_HelpSection_ErrorCodes_Internal$+" (10-19):"
#LSCOM_Locale_HelpSectionFormatted_ErrorCodes_External$ = " * "+#LSCOM_Locale_HelpSection_ErrorCodes_External$+" (20-29):"
#LSCOM_Locale_HelpSectionFormatted_ErrorCodes_Application$ = " * "+#LSCOM_Locale_HelpSection_ErrorCodes_Application$+" (30-39):"
Loading

0 comments on commit 3afcd52

Please sign in to comment.