Skip to content
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

Fixes to be in sync with codegangsta #119

Merged
merged 1 commit into from
Dec 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ var globalConfig *GlobalConfig
var rootPath string

func main() {

app := cli.NewApp()
app.Name = "ink"
app.Usage = "An elegant static blog generator"
app.Author = "https://github.com/imeoer"
app.Email = "imeoer@gmail.com"
app.Authors = []*cli.Author{
{Name: "Harrison", Email: "harrison@lolwut.com"},
{Name: "Oliver Allen", Email: "oliver@toyshop.com"},
}
//app.Email = "imeoer@gmail.com"
app.Version = VERSION
app.Commands = []cli.Command{
app.Commands = []*cli.Command{
{
Name: "build",
Usage: "Generate blog to public folder",
Expand Down Expand Up @@ -105,49 +109,49 @@ func main() {
Name: "new",
Usage: "Creates a new article",
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "hide",
Usage: "Hides the article",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "top",
Usage: "Places the article at the top",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "post",
Usage: "The article is a post",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "page",
Usage: "The article is a page",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "draft",
Usage: "The article is a draft",
},

cli.StringFlag{
&cli.StringFlag{
Name: "title",
Usage: "Article title",
},
cli.StringFlag{
&cli.StringFlag{
Name: "author",
Usage: "Article author",
},
cli.StringFlag{
&cli.StringFlag{
Name: "cover",
Usage: "Article cover path",
},
cli.StringFlag{
&cli.StringFlag{
Name: "date",
Usage: "The date and time on which the article was created (2006-01-02 15:04:05)",
},
cli.StringFlag{
&cli.StringFlag{
Name: "file",
Usage: "The path of where the article will be stored",
},

cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "tag",
Usage: "Adds a tag to the article",
},
Expand All @@ -163,8 +167,8 @@ func main() {
}

func ParseGlobalConfigByCli(c *cli.Context, develop bool) {
if len(c.Args()) > 0 {
rootPath = c.Args()[0]
if c.Args().Len() > 0 {
rootPath = c.Args().Slice()[0]
} else {
rootPath = "."
}
Expand Down Expand Up @@ -207,8 +211,8 @@ func New(c *cli.Context) {

// Parse args
args := c.Args()
if len(args) > 0 {
blogTitle = args[0]
if args.Len() > 0 {
blogTitle = args.Slice()[0]
}
if blogTitle == "" {
if c.String("title") != "" {
Expand All @@ -223,8 +227,8 @@ func New(c *cli.Context) {
fileName = c.String("file")
}

if len(args) > 1 {
author = args[1]
if args.Len() > 1 {
author = args.Slice()[1]
}
if author == "" {
author = c.String("author")
Expand Down Expand Up @@ -349,13 +353,13 @@ func Convert(c *cli.Context) {
// Parse arguments
var sourcePath, rootPath string
args := c.Args()
if len(args) > 0 {
sourcePath = args[0]
if args.Len() > 0 {
sourcePath = args.Slice()[0]
} else {
Fatal("Please specify the posts source path")
}
if len(args) > 1 {
rootPath = args[1]
if args.Len() > 1 {
rootPath = args.Slice()[1]
} else {
rootPath = "."
}
Expand Down