@@ -1,40 +0,0 @@
|
|||||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
|
||||||
//
|
|
||||||
// Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||||
// copyright notice and this permission notice appear in all copies.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
|
||||||
"go.probo.inc/probo/pkg/cmd/iostreams"
|
|
||||||
"go.probo.inc/probo/pkg/proboctl/root"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ios := iostreams.System()
|
|
||||||
ios.ApplyColorProfile()
|
|
||||||
|
|
||||||
f := &cmdutil.Factory{
|
|
||||||
IOStreams: ios,
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := root.NewCmdRoot(f)
|
|
||||||
|
|
||||||
if err := cmd.Execute(); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
|
||||||
//
|
|
||||||
// Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||||
// copyright notice and this permission notice appear in all copies.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
package mdtoprosemirror
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
|
||||||
"go.probo.inc/probo/pkg/prosemirror"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCmdMdToProsemirror(f *cmdutil.Factory) *cobra.Command {
|
|
||||||
var flagContent string
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "md-to-prosemirror",
|
|
||||||
Short: "Convert markdown to ProseMirror JSON",
|
|
||||||
Example: ` # Convert from flag
|
|
||||||
proboctl md-to-prosemirror --content "# Hello"
|
|
||||||
|
|
||||||
# Convert from stdin
|
|
||||||
echo "# Hello" | proboctl md-to-prosemirror
|
|
||||||
|
|
||||||
# Convert from file
|
|
||||||
proboctl md-to-prosemirror < document.md`,
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
var input string
|
|
||||||
if flagContent != "" {
|
|
||||||
input = flagContent
|
|
||||||
} else {
|
|
||||||
data, err := io.ReadAll(f.IOStreams.In)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("cannot read from stdin: %w", err)
|
|
||||||
}
|
|
||||||
input = string(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
doc, err := prosemirror.ParseMarkdown(input)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
out, err := json.Marshal(doc)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("cannot marshal prosemirror document: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintln(f.IOStreams.Out, string(out))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.Flags().StringVar(
|
|
||||||
&flagContent,
|
|
||||||
"content",
|
|
||||||
"",
|
|
||||||
"Markdown content to convert (reads from stdin if not provided)",
|
|
||||||
)
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
|
||||||
//
|
|
||||||
// Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||||
// copyright notice and this permission notice appear in all copies.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
package root
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"go.probo.inc/probo/pkg/cmd/cmdutil"
|
|
||||||
"go.probo.inc/probo/pkg/proboctl/mdtoprosemirror"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCmdRoot(f *cmdutil.Factory) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "proboctl <command> [flags]",
|
|
||||||
Short: "Probo admin CLI",
|
|
||||||
Long: "proboctl is a command-line tool for Probo administrative operations.",
|
|
||||||
SilenceUsage: true,
|
|
||||||
SilenceErrors: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.AddCommand(mdtoprosemirror.NewCmdMdToProsemirror(f))
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user