pyrecli 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyrecli-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyrecli
3
+ Version: 0.2.1
4
+ Summary: Command line utilities for DiamondFire templates
5
+ Home-page: https://github.com/Amp63/pyrecli
6
+ License: MIT
7
+ Keywords: diamondfire,minecraft,template,cli
8
+ Author: Amp
9
+ Requires-Python: >=3.10,<3.13
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Dist: dfpyre (>=0.9.3,<0.10.0)
16
+ Project-URL: Repository, https://github.com/Amp63/pyrecli
17
+ Description-Content-Type: text/markdown
18
+
19
+ # pyrecli
20
+
21
+ Command line utilities for DiamondFire templates
22
+
23
+ ## Installation
24
+
25
+ Run the following command in a terminal:
26
+
27
+ ```sh
28
+ pip install pyrecli
29
+ ```
30
+
31
+ ## Commands
32
+
33
+ - `scan`: Scan all templates on the plot and dump them to a text file (requires [CodeClient](github.com/DFOnline/CodeClient))
34
+ - `send`: Send template items to DiamondFire (requires [CodeClient](github.com/DFOnline/CodeClient))
35
+ - `rename`: Rename all occurences of a variable (including text codes)
36
+ - `script`: Generate python scripts from template data
37
+ - `grabinv`: Save all templates in your Minecraft inventory to a file (requires [CodeClient](github.com/DFOnline/CodeClient))
38
+ - `docs`: Generate markdown documentation from template data
39
+ - `slice`: Slice a template into multiple smaller templates
40
+
41
+
42
+ ## What is this useful for?
43
+
44
+ - Backing up a plot
45
+ - Getting an accurate text representation of DF code
46
+ - Open sourcing
47
+ - Version control
48
+ - Large scale refactoring
49
+
50
+
51
+ ## Example Command Usages
52
+
53
+ ### Scan
54
+
55
+ **[Requires CodeClient]**
56
+
57
+ Grabs all of the templates on your current plot and saves them to a file.
58
+ You will need to run `/auth` in-game to authorize this action.
59
+
60
+ Example:
61
+ ```sh
62
+ # Dumps all template data into templates.dfts
63
+ pyrecli scan templates.dfts
64
+ ```
65
+
66
+ ### Send
67
+
68
+ **[Requires CodeClient]**
69
+
70
+ Sends all templates in a file back to DiamondFire.
71
+ Essentially the reverse of `scan`.
72
+
73
+ Example:
74
+ ```sh
75
+ pyrecli send templates.dfts
76
+ ```
77
+
78
+ ### Rename
79
+
80
+ Renames all occurences of a variable in a list of templates.
81
+ You can run this command on a single template, or on an entire plot if a variable is used in many places.
82
+
83
+ This command still requires thorough testing, so make sure you have a backup of your plot before using this command on a large scale.
84
+
85
+ Example:
86
+ ```sh
87
+ # Changes all variables named `foo` to `bar`.
88
+ pyrecli rename templates.dfts foo bar
89
+
90
+ # You can also target a specific scope.
91
+ # This changes all occurences of the game variable `plotData` to `gameData`.
92
+ pyrecli rename templates.dfts plotData gameData -s game
93
+ ```
94
+
95
+ By default, this modifies the input file in-place, but you can use the `--output_path` flag to output the renamed templates to a new file:
96
+ ```sh
97
+ pyrecli rename templates.dfts foo bar --output_path renamed_templates.dfts
98
+ ```
99
+
100
+ ### Script
101
+
102
+ Generates Python scripts from template data.
103
+
104
+ Example:
105
+ ```sh
106
+ # Convert templates into individual scripts and store them in directory `plot_templates`
107
+ pyrecli script templates.dfts plot_templates
108
+
109
+ # Convert templates into scripts and put them into a single file `plot_templates.py`
110
+ pyrecli script templates.dfts plot_templates.py --onefile
111
+ ```
112
+
113
+
114
+ ### Grabinv
115
+
116
+ **[Requires CodeClient]**
117
+
118
+ Scans your inventory for templates and saves them to a file.
119
+
120
+ Example:
121
+ ```sh
122
+ # Save inventory templates to `templates.dfts`
123
+ pyrecli grabinv templates.dfts
124
+ ```
125
+
126
+
127
+ ### Docs
128
+
129
+ Generates a Markdown documentation file for a list of templates.
130
+
131
+ Example:
132
+ ```sh
133
+ # Generate documentation and save it to `plot_docs.md`
134
+ pyrecli docs templates.dfts plot_docs.md "My Plot Docs"
135
+ ```
136
+
137
+
138
+ ### Slice
139
+
140
+ Slices a single template into multiple smaller templates.
141
+ This is useful for resizing templates to fit on a smaller plot.
142
+
143
+ If multiple templates are passed, only the first one will be used.
144
+
145
+ **NOTE: This feature is not fully implemented yet. Any templates with Control::Return blocks may not work properly if sliced.**
146
+
147
+ Example:
148
+ ```sh
149
+ # Slices the first template in `templates.dfts` with a target length of 50 and stores them in `sliced_templates.dfts`
150
+ pyrecli slice templates.dfts sliced_templates.dfts 50
151
+ ```
152
+
@@ -0,0 +1,133 @@
1
+ # pyrecli
2
+
3
+ Command line utilities for DiamondFire templates
4
+
5
+ ## Installation
6
+
7
+ Run the following command in a terminal:
8
+
9
+ ```sh
10
+ pip install pyrecli
11
+ ```
12
+
13
+ ## Commands
14
+
15
+ - `scan`: Scan all templates on the plot and dump them to a text file (requires [CodeClient](github.com/DFOnline/CodeClient))
16
+ - `send`: Send template items to DiamondFire (requires [CodeClient](github.com/DFOnline/CodeClient))
17
+ - `rename`: Rename all occurences of a variable (including text codes)
18
+ - `script`: Generate python scripts from template data
19
+ - `grabinv`: Save all templates in your Minecraft inventory to a file (requires [CodeClient](github.com/DFOnline/CodeClient))
20
+ - `docs`: Generate markdown documentation from template data
21
+ - `slice`: Slice a template into multiple smaller templates
22
+
23
+
24
+ ## What is this useful for?
25
+
26
+ - Backing up a plot
27
+ - Getting an accurate text representation of DF code
28
+ - Open sourcing
29
+ - Version control
30
+ - Large scale refactoring
31
+
32
+
33
+ ## Example Command Usages
34
+
35
+ ### Scan
36
+
37
+ **[Requires CodeClient]**
38
+
39
+ Grabs all of the templates on your current plot and saves them to a file.
40
+ You will need to run `/auth` in-game to authorize this action.
41
+
42
+ Example:
43
+ ```sh
44
+ # Dumps all template data into templates.dfts
45
+ pyrecli scan templates.dfts
46
+ ```
47
+
48
+ ### Send
49
+
50
+ **[Requires CodeClient]**
51
+
52
+ Sends all templates in a file back to DiamondFire.
53
+ Essentially the reverse of `scan`.
54
+
55
+ Example:
56
+ ```sh
57
+ pyrecli send templates.dfts
58
+ ```
59
+
60
+ ### Rename
61
+
62
+ Renames all occurences of a variable in a list of templates.
63
+ You can run this command on a single template, or on an entire plot if a variable is used in many places.
64
+
65
+ This command still requires thorough testing, so make sure you have a backup of your plot before using this command on a large scale.
66
+
67
+ Example:
68
+ ```sh
69
+ # Changes all variables named `foo` to `bar`.
70
+ pyrecli rename templates.dfts foo bar
71
+
72
+ # You can also target a specific scope.
73
+ # This changes all occurences of the game variable `plotData` to `gameData`.
74
+ pyrecli rename templates.dfts plotData gameData -s game
75
+ ```
76
+
77
+ By default, this modifies the input file in-place, but you can use the `--output_path` flag to output the renamed templates to a new file:
78
+ ```sh
79
+ pyrecli rename templates.dfts foo bar --output_path renamed_templates.dfts
80
+ ```
81
+
82
+ ### Script
83
+
84
+ Generates Python scripts from template data.
85
+
86
+ Example:
87
+ ```sh
88
+ # Convert templates into individual scripts and store them in directory `plot_templates`
89
+ pyrecli script templates.dfts plot_templates
90
+
91
+ # Convert templates into scripts and put them into a single file `plot_templates.py`
92
+ pyrecli script templates.dfts plot_templates.py --onefile
93
+ ```
94
+
95
+
96
+ ### Grabinv
97
+
98
+ **[Requires CodeClient]**
99
+
100
+ Scans your inventory for templates and saves them to a file.
101
+
102
+ Example:
103
+ ```sh
104
+ # Save inventory templates to `templates.dfts`
105
+ pyrecli grabinv templates.dfts
106
+ ```
107
+
108
+
109
+ ### Docs
110
+
111
+ Generates a Markdown documentation file for a list of templates.
112
+
113
+ Example:
114
+ ```sh
115
+ # Generate documentation and save it to `plot_docs.md`
116
+ pyrecli docs templates.dfts plot_docs.md "My Plot Docs"
117
+ ```
118
+
119
+
120
+ ### Slice
121
+
122
+ Slices a single template into multiple smaller templates.
123
+ This is useful for resizing templates to fit on a smaller plot.
124
+
125
+ If multiple templates are passed, only the first one will be used.
126
+
127
+ **NOTE: This feature is not fully implemented yet. Any templates with Control::Return blocks may not work properly if sliced.**
128
+
129
+ Example:
130
+ ```sh
131
+ # Slices the first template in `templates.dfts` with a target length of 50 and stores them in `sliced_templates.dfts`
132
+ pyrecli slice templates.dfts sliced_templates.dfts 50
133
+ ```
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyrecli"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "Command line utilities for DiamondFire templates"
5
5
  authors = ["Amp"]
6
6
  readme = "README.md"
@@ -11,6 +11,7 @@ keywords = ["diamondfire", "minecraft", "template", "cli"]
11
11
 
12
12
  [tool.poetry.dependencies]
13
13
  python = ">=3.10,<3.13"
14
+ dfpyre = "^0.9.3"
14
15
 
15
16
 
16
17
  [tool.poetry.scripts]
@@ -11,6 +11,14 @@ from pyrecli.command.docs import docs_command
11
11
  from pyrecli.command.slice import slice_command
12
12
 
13
13
 
14
+ def rename_target_scope(value):
15
+ SCOPES = {'game', 'saved', 'local', 'line'}
16
+ if value not in SCOPES:
17
+ raise argparse.ArgumentTypeError(f'Expected one of {SCOPES} for rename target scope')
18
+ return value
19
+
20
+
21
+
14
22
  def slice_target_length(value):
15
23
  MINIMUM_LENGTH = 5
16
24
  ivalue = int(value)
@@ -44,7 +52,7 @@ def main():
44
52
  parser_rename.add_argument('input_path', help='The file containing template data', type=str)
45
53
  parser_rename.add_argument('var_to_rename', help='The variable to rename', type=str)
46
54
  parser_rename.add_argument('new_var_name', help='The new name for the variable', type=str)
47
- parser_rename.add_argument('--var_to_rename_scope', '-s', help='The scope to match', type=str, default=None)
55
+ parser_rename.add_argument('--var_to_rename_scope', '-s', help='The scope to match', type=rename_target_scope, default=None)
48
56
  parser_rename.add_argument('--output_path', '-o', help='The file to output to', type=str, default=None)
49
57
 
50
58
  parser_grabinv = subparsers.add_parser('grabinv', help='Save all templates in the inventory to a file with CodeClient')
@@ -61,7 +69,7 @@ def main():
61
69
  parser_slice.add_argument('input_path', help='The file containing template data', type=str)
62
70
  parser_slice.add_argument('output_path', help='The file to output template data to', type=str)
63
71
  parser_slice.add_argument('target_length', help='The maximum length of each sliced template', type=slice_target_length)
64
-
72
+
65
73
  parsed_args = parser.parse_args()
66
74
 
67
75
  match parsed_args.command:
pyrecli-0.2.0/PKG-INFO DELETED
@@ -1,66 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pyrecli
3
- Version: 0.2.0
4
- Summary: Command line utilities for DiamondFire templates
5
- Home-page: https://github.com/Amp63/pyrecli
6
- License: MIT
7
- Keywords: diamondfire,minecraft,template,cli
8
- Author: Amp
9
- Requires-Python: >=3.10,<3.13
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Project-URL: Repository, https://github.com/Amp63/pyrecli
16
- Description-Content-Type: text/markdown
17
-
18
- # pyrecli
19
-
20
- Command line utilities for DiamondFire templates
21
-
22
- ## Installation
23
-
24
- Run the following command in a terminal:
25
-
26
- ```sh
27
- pip install pyrecli
28
- ```
29
-
30
- ## Commands
31
-
32
- - `scan`: Scan all templates on the plot and dump them to a text file (requires [CodeClient](github.com/DFOnline/CodeClient))
33
- - `send`: Send template items to DiamondFire (requires [CodeClient](github.com/DFOnline/CodeClient))
34
- - `rename`: Rename all occurences of a variable (including text codes)
35
- - `script`: Generate python scripts from template data
36
- - `grabinv`: Save all templates in your Minecraft inventory to a file (requires [CodeClient](github.com/DFOnline/CodeClient))
37
- - `docs`: Generate markdown documentation from template data
38
-
39
-
40
- ## What is this useful for?
41
-
42
- - Backing up a plot
43
- - Getting an accurate text representation of DF code
44
- - Open sourcing
45
- - Version control
46
- - Large scale refactoring
47
-
48
-
49
- ## Example Usage
50
-
51
- These two commands will scan your plot, convert each template into a python script, then place the scripts into a directory called `myplot`.
52
-
53
- ```sh
54
- pyrecli scan templates.dfts
55
- pyrecli script templates.dfts myplot
56
- ```
57
-
58
- If you prefer the templates to be outputted to a single file, use the `--onefile` flag:
59
-
60
- ```sh
61
- pyrecli scan templates.dfts
62
- pyrecli script templates.dfts myplot.py --onefile
63
- ```
64
-
65
- For more information about generating scripts, run `pyrecli script -h`.
66
-
pyrecli-0.2.0/README.md DELETED
@@ -1,48 +0,0 @@
1
- # pyrecli
2
-
3
- Command line utilities for DiamondFire templates
4
-
5
- ## Installation
6
-
7
- Run the following command in a terminal:
8
-
9
- ```sh
10
- pip install pyrecli
11
- ```
12
-
13
- ## Commands
14
-
15
- - `scan`: Scan all templates on the plot and dump them to a text file (requires [CodeClient](github.com/DFOnline/CodeClient))
16
- - `send`: Send template items to DiamondFire (requires [CodeClient](github.com/DFOnline/CodeClient))
17
- - `rename`: Rename all occurences of a variable (including text codes)
18
- - `script`: Generate python scripts from template data
19
- - `grabinv`: Save all templates in your Minecraft inventory to a file (requires [CodeClient](github.com/DFOnline/CodeClient))
20
- - `docs`: Generate markdown documentation from template data
21
-
22
-
23
- ## What is this useful for?
24
-
25
- - Backing up a plot
26
- - Getting an accurate text representation of DF code
27
- - Open sourcing
28
- - Version control
29
- - Large scale refactoring
30
-
31
-
32
- ## Example Usage
33
-
34
- These two commands will scan your plot, convert each template into a python script, then place the scripts into a directory called `myplot`.
35
-
36
- ```sh
37
- pyrecli scan templates.dfts
38
- pyrecli script templates.dfts myplot
39
- ```
40
-
41
- If you prefer the templates to be outputted to a single file, use the `--onefile` flag:
42
-
43
- ```sh
44
- pyrecli scan templates.dfts
45
- pyrecli script templates.dfts myplot.py --onefile
46
- ```
47
-
48
- For more information about generating scripts, run `pyrecli script -h`.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes