File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,14 +45,20 @@ The DevHub CLI provides powerful theme management capabilities for synchronizing
4545Before using theme commands, you need to initialize your environment:
4646
4747``` bash
48+ # Initialize in current directory
4849devhub theme init
50+
51+ # Initialize in a new directory
52+ devhub theme init mybrand-corporate-theme
4953```
5054
5155This command will:
5256- Create a ` .env ` file with your DevHub API credentials
5357- Generate a ` .gitignore ` file with appropriate exclusions
5458- Create a ` devhub.conf.json ` configuration file
5559
60+ When specifying a directory, the command will create the directory if it doesn't exist and initialize all configuration files within it.
61+
5662You'll be prompted to enter:
5763- ` DEVHUB_API_KEY ` - Your OAuth1 API key
5864- ` DEVHUB_API_SECRET ` - Your OAuth1 API secret
Original file line number Diff line number Diff line change @@ -197,13 +197,39 @@ def init_config():
197197
198198
199199@theme .command ()
200- def init ():
200+ @click .argument ('directory' , required = False )
201+ def init (directory ):
201202 """Initialize theme environment configuration."""
202- click .echo (click .style ('Initializing DevHub environment configuration...' , fg = 'green' ))
203+ original_working_dir = os .environ .get ('WORKING_DIR' , os .getcwd ())
204+
205+ if directory :
206+ # Check if directory already exists
207+ if os .path .exists (directory ):
208+ click .echo (click .style (f'Error: Directory "{ directory } " already exists' , fg = 'red' ))
209+ return
210+
211+ # Create the directory
212+ try :
213+ os .makedirs (directory , exist_ok = False )
214+ click .echo (click .style (f'Created directory: { directory } ' , fg = 'green' ))
215+ except OSError as e :
216+ click .echo (click .style (f'Error creating directory "{ directory } ": { e } ' , fg = 'red' ))
217+ return
218+
219+ # Update WORKING_DIR to the new directory
220+ absolute_directory = os .path .abspath (directory )
221+ os .environ ['WORKING_DIR' ] = absolute_directory
222+ click .echo (click .style (f'Initializing DevHub environment configuration in { absolute_directory } ...' , fg = 'green' ))
223+ else :
224+ click .echo (click .style ('Initializing DevHub environment configuration...' , fg = 'green' ))
203225
204- init_env ()
205- init_gitignore ()
206- init_config ()
226+ try :
227+ init_env ()
228+ init_gitignore ()
229+ init_config ()
230+ finally :
231+ # Restore original WORKING_DIR
232+ os .environ ['WORKING_DIR' ] = original_working_dir
207233
208234
209235@theme .command ()
You can’t perform that action at this time.
0 commit comments