Skip to content

Commit

Permalink
Merge pull request #10 from sixty4k/configure_run_command
Browse files Browse the repository at this point in the history
Make run command more configurable
  • Loading branch information
akmittal authored Nov 29, 2018
2 parents a58d45d + 87eed1d commit 0229f0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions Hugofy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ class HugoserverCommand(sublime_plugin.TextCommand):
def run(self,edit):
setvars()
server=settings.get("Server")
theme=settings.get("DefaultTheme")
startCmd = ["hugo", "server"]
if server["THEME_FLAG"]:
startCmd = startCmd + ["--theme={}".format(server["THEME"])]
if server["DRAFTS_FLAG"]:
startCmd = startCmd + ["--buildDrafts"]

startCmd = startCmd + ["--watch", "--port={}".format(server["PORT"])]

try:
startCmd = ["hugo", "server", "--theme={}".format(theme), "--buildDrafts", "--watch", "--port={}".format(server["PORT"])]
out=subprocess.Popen(startCmd,stderr=subprocess.STDOUT,universal_newlines=True)
sublime.status_message('Server Started: {}'.format(startCmd))
except:
Expand Down
7 changes: 4 additions & 3 deletions hugofy.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
//name of theme to run hugo with
"DefaultTheme": "bootstrap",
//root directory for hugo website use double backwork slash for windows
//root directory for hugo websites use double backwork slash for windows
//e.g. windows C:\\Users\\myusername\\
//e.g. Linux/Mac /home/myusername
"Directory": "C:\\Users\\amitm\\OneDrive\\Documents\\Projects\\hugo\\mySite",
"Server":
{
"PORT": 8000 //server port number
"THEME_FLAG": true //use `--theme` flag
"DRAFTS_FLAG": true //use `--buildDrafts` flag
"THEME": "bootstrap" //theme used by `--theme` flag
},
//website name
"Sitename": "MyFirstsite"
Expand Down

0 comments on commit 0229f0b

Please sign in to comment.