Skip to content

Commit

Permalink
Help menu implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-Byrne committed May 3, 2023
1 parent bb4ef56 commit 24ab7e3
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 26 deletions.
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,52 @@ git clone https://github.com/Justin-Byrne/ClassGenerator.git

## Usage

> Python
> Help menu
```sh
> python3 BuildClass.py <source> [<destination>] [<flag>] [<flag_value>]
```
python3 BuildClass.py {<source>} [<destination>] [flags] [args[|args...]]
PATHS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
source File or directory location of javascript file(s) to convert
usage:
(single) "/javascript/classes/one.js"
(multiple) "/javascript/classes"
destination File or directory location to save class diagrams
usage:
(single) "/javascript/classes/output/one.txt"
(multiple) "/javascript/classes/output"
FLAGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-o, --omit "<filename>" Omit the following filenames from the source directory
usage:
(single) --omit "file1"
(multiple) --omit "file1|file2|file3"
-s, --skin "<skinparam>" Embed skin parameters within the class uml generated
usage:
(single) --skin "skinparam+one+1"
(multiple) --skin "skinparam+one+1|skinparam+two+2"
-m, --make "<image_type>" Make the class generated diagram into an image
usage:
(single) --make "png"
(multiple) --make "png|svg|eps"
-l, --link Link available classes to generated class diagrams
usage: --link
-h, --help Display this help menu
usage: --help
```

## Configuration
Expand Down
19 changes: 18 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.7.8] - 2023-05-03
### Added
- Help menu to `get_commands ( )`

### Changed
- Minor error refinement:
- `view_arguments ( )`
- `create_2d_list ( )`
- `entry_padding ( )`
- `parse_commands ( )`
- `repeat_character ( )`
- `is_file ( )`

### Fixed
- Path validation for PlantUml program executable under `parse_commands ( )`

## [0.7.7] - 2023-05-03
### Fixed
- PlantUml program executable location management under `parse_commands ( )`
Expand Down Expand Up @@ -133,7 +149,8 @@ All notable changes to this project will be documented in this file.

| Version | Date | Commit | Comments |
| :-----: | :--------: | :----------------------------------------------------------------------: | :---------------------------------------------------------------- |
| 0.7.7 | 2023-05-03 | Current | PlantUml program executable location management
| 0.7.8 | 2023-05-03 | Current | Help menu implemented
| 0.7.7 | 2023-05-03 | [bb4ef56](https://github.com/Justin-Byrne/ClassGenerator/commit/bb4ef56) | PlantUml program executable location management
| 0.7.6 | 2023-05-02 | [63dab81](https://github.com/Justin-Byrne/ClassGenerator/commit/63dab81) | Fully implemented class linker
| 0.6.5 | 2023-04-29 | [ed8937b](https://github.com/Justin-Byrne/ClassGenerator/commit/ed8937b) | Expanded config, validation, and debugging
| 0.5.5 | 2023-04-27 | [ae2d7e9](https://github.com/Justin-Byrne/ClassGenerator/commit/ae2d7e9) | Finalized generator processes and unit-tests
Expand Down
2 changes: 1 addition & 1 deletion source/app/BuildClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def main ( commands ):
if Generator ( arguments ) and arguments [ 'link_files' ]:

Linker ( arguments )


main ( sys.argv )
2 changes: 1 addition & 1 deletion source/app/utilities/custom/cleanup/clean_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create_2d_list ( depth ):

if depth < 1 or depth == None:

print ( 'create_2d_list.py requires a depth value param of at least 1 !' )
print ( ' >> [ERROR] create_2d_list.py\n\t~ Requires a depth value param of at least 1 !' )

return ERROR

Expand Down
2 changes: 0 additions & 2 deletions source/app/utilities/custom/debug/view_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ def view_arguments ( arguments ):

print ( '-' * 100 )

print ( "Flag: \t\t", arguments [ 'flag' ] )

print ( "Source: \t", arguments [ 'source' ] )

print ( "Destination: \t", arguments [ 'destination' ] )
Expand Down
45 changes: 43 additions & 2 deletions source/app/utilities/system/get_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,50 @@ def get_commands ( commands ):
arguments = parse_commands ( commands )


if arguments [ 'help_menu' ]:

menu = [
'PlantUML class generator for JavaScript\n\n'
'python3 BuildClass.py {<source>} [<destination>] [flags] [args[|args...]]\n\n'
'PATHS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n\n'
'source\t\t\t\tFile or directory location of javascript file(s) to convert\n\n'
'\t\t\t\tusage: \n'
'\t\t\t\t\t(single) "/javascript/classes/one.js"\n'
'\t\t\t\t\t(multiple) "/javascript/classes"\n\n'
'destination\t\t\tFile or directory location to save class diagrams\n\n'
'\t\t\t\tusage: \n'
'\t\t\t\t\t(single) "/javascript/classes/output/one.txt"\n'
'\t\t\t\t\t(multiple) "/javascript/classes/output"\n\n'
'FLAGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n\n'
'-o, --omit "<filename>"\t\tOmit the following filenames from the source directory\n\n'
'\t\t\t\tusage: \n'
'\t\t\t\t\t(single) --omit "file1"\n'
'\t\t\t\t\t(multiple) --omit "file1|file2|file3"\n\n'
'-s, --skin "<skinparam>"\tEmbed skin parameters within the class uml generated\n\n'
'\t\t\t\tusage: \n'
'\t\t\t\t\t(single) --skin "skinparam+one+1"\n'
'\t\t\t\t\t(multiple) --skin "skinparam+one+1|skinparam+two+2"\n\n'
'-m, --make "<image_type>"\tMake the class generated diagram into an image\n\n'
'\t\t\t\tusage: \n'
'\t\t\t\t\t(single) --make "png"\n'
'\t\t\t\t\t(multiple) --make "png|svg|eps"\n\n'
'-l, --link\t\t\tLink available classes to generated class diagrams\n\n'
'\t\t\t\tusage: --link\n\n'
'-h, --help\t\t\tDisplay this help menu\n\n'
'\t\t\t\tusage: --help'
]

for line in menu:

print ( line )


return ERROR;


if arguments [ 'source' ] == None: # CHECK WHETHR A SOURCE IS PRESENT

print ( 'BuildClass.py requires a single source... try again !' )
print ( ' >> [ERROR] BuildClass.py\n\t~ Requires a single source !' )

return ERROR

Expand All @@ -23,7 +64,7 @@ def get_commands ( commands ):

if is_directory ( arguments [ 'source'] ) and is_file ( arguments [ 'destination' ], None ):

print ( 'BuildClass.py a whole directory cannot be parsed into a single file... try again !' )
print ( ' >> [ERROR] BuildClass.py\n\t~ A whole directory cannot be parsed into a single file !' )

return ERROR

Expand Down
2 changes: 1 addition & 1 deletion source/app/utilities/system/list/create_2d_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def create_2d_list ( depth ):

if depth < 1 or depth == None:

print ( 'create_2d_list.py requires a depth value param of at least 1 !' )
print ( ' >> [ERROR] create_2d_list.py\n\t~ Requires a depth value param of at least 1 !' )

return ERROR

Expand Down
4 changes: 2 additions & 2 deletions source/app/utilities/system/list/entry_padding.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def entry_padding ( tuple_list, padding = 3, entry = 0 ):

if padding < 1:

print ( 'entry_padding.py requires a padding param value of at least 1 !')
print ( ' >> [ERROR] entry_padding.py\n\t~ Requires a padding param value of at least 1 !' )

return ERROR


if entry > get_max_tuple_length ( tuple_list ) or entry < 0:

print ( 'entry_padding.py entry param value is not uniformly accessible through tuple_list param value !')
print ( ' >> [ERROR] entry_padding.py\n\t~ Entry param value is not uniformly accessible through tuple_list param value !' )

return ERROR

Expand Down
36 changes: 26 additions & 10 deletions source/app/utilities/system/parse_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ def parse_commands ( commands ):
#### GLOBALS ####################################

arguments = {
'flag': None,
'source': None,
'destination': None,
'link_files': False
'link_files': False,
'help_menu': False
}

regexes = {
'help_menu': r'\s*-h\s*|\s*--help\s*',
'locations': r'(\/\w+[^\s*]+)',
'omit_files': r'\s*-o\s*|\s*--omit\s*',
'skin_param': r'\s*-s\s*|\s*--skin\s*',
Expand Down Expand Up @@ -58,6 +59,12 @@ def check_command_line ( ):

match regex:

case 'help_menu':

arguments [ 'help_menu' ] = True

break

case 'locations':

if arguments [ 'source' ] == None:
Expand Down Expand Up @@ -161,21 +168,30 @@ def check_plant_uml ( ):

data = open ( './config/config.txt', 'r' ).read ( )

path = abspath ( expanduser ( re.search ( r'PLANTUML PATH\s*path=([^\s]+)', data ).group ( 1 ) ) )

regex = re.compile ( r'[P|p][L|l][A|a][N|n][T|t][U|u][M|m][L|l][^j]+jar' )

try:

path = re.search ( r'PLANTUML PATH\s*path=([^\s]+)', data ).group ( 1 )

path = abspath ( expanduser ( path ) )

regex = re.compile ( r'[P|p][L|l][A|a][N|n][T|t][U|u][M|m][L|l][^j]+jar' )


for file in os.listdir ( os.fsdecode ( path ) ):

if regex.match ( file ):

for file in os.listdir ( os.fsdecode ( path ) ):
program = file

if regex.match ( file ):

program = file
if program:

arguments.update ( { 'plant_path': f'{path}/{program}' } )

if program:
except Exception:

arguments.update ( { 'plant_path': f'{path}/{program}' } )
print ( ' >> [ERROR] parse_commands.py\n\t~ Could not locate PlantUml path or program !\n\t~ Please check config.txt !' )

#### LOGIC ####################################

Expand Down
4 changes: 2 additions & 2 deletions source/app/utilities/system/string/repeat_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ def repeat_character ( character, times ):

if len ( character ) != 1:

print ( 'repeat_character.py accepts a single character param only !' )
print ( ' >> [ERROR] repeat_character.py\n\t~ Accepts a single character param only !' )

return ERROR


if times < 2 or times == None:

print ( 'repeat_character.py accepts a times value of above 1 only !')
print ( ' >> [ERROR] repeat_character.py\n\t~ Accepts a times value of above 1 only !' )

return ERROR

Expand Down
2 changes: 1 addition & 1 deletion source/app/utilities/system/validation/is_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def is_file ( path, type ):

else:

print ( "type: {}, is not a valid file type !".format ( type ) );
print ( ' >> [ERROR] is_file.py\n', f'\t~ Type: "{type}", is not a valid file type !' )

return False

Expand Down

0 comments on commit 24ab7e3

Please sign in to comment.