-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for external applications #1860
Changes from 5 commits
831356c
239bbe2
3e715b8
9d483a4
60febd7
ee0cd6c
0c37532
64d7b5c
9e23358
8c17b76
262cad2
d946b5b
e37a900
92df607
5e1a2a8
0c42a21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2015 The Hugo Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package api | ||
|
||
import ( | ||
"github.com/spf13/hugo/commands" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func Run(flags []string) { | ||
commands.Execute(flags) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't hugoCmd.ExecuteC() do the trick? Note the C at the end, then you can return an error to the client in case of errors. You would probably have to duplicate parts of commands.Execute -- but it would make a slightly better API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bep that would be a good idea, but to do so I would have to export HugoCmd, wouldn't I? |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of my thoughts with an API was to limit it somehow to what the external tools needs. I know this is hard with the current setup, but if you limit it to the hugoCmd (for starters), you could name this func Build() or something. Then it also would be possible to create a more natural API than the CLI flags. |
||
|
||
func Reset() { | ||
commands.ClearSite() | ||
viper.Reset() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ import ( | |
|
||
func main() { | ||
runtime.GOMAXPROCS(runtime.NumCPU()) | ||
commands.Execute() | ||
commands.Execute(nil) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2016