示例#1
0
文件: post.go 项目: minodisk/qiitactl
// DeletePost deletes your post from Qiita with a specified file.
func (r DeletePostRunner) Run(c api.Client, o GlobalOptions, w io.Writer) (err error) {
	post, err := model.NewPostWithOSFile(*r.File)
	if err != nil {
		return
	}
	err = post.Delete(c)
	if err != nil {
		return
	}
	err = post.Save(nil)
	return
}
示例#2
0
文件: post.go 项目: minodisk/qiitactl
// CreatePost creates a new post in Qiita with a specified file.
func (r CreatePostRunner) Run(c api.Client, o GlobalOptions, w io.Writer) (err error) {
	opts := model.CreationOptions{
		Tweet: *r.Tweet,
		Gist:  *r.Gist,
	}

	post, err := model.NewPostWithOSFile(*r.File)
	if err != nil {
		return
	}
	err = post.Create(c, opts)
	if err != nil {
		return
	}
	err = post.Save(nil)
	return
}
示例#3
0
文件: post.go 项目: minodisk/qiitactl
func getID(id string, file *os.File) (i string, err error) {
	if id != "" {
		i = id
		return
	}
	if file != nil {
		post, err := model.NewPostWithOSFile(file)
		if err != nil {
			return "", err
		}
		i = post.ID
		return i, nil
	}

	err = fmt.Errorf("fetch post: id or filename is required")
	return
}