diff --git a/cli/cmd/enrich.go b/cli/cmd/enrich.go new file mode 100644 index 0000000..726a4e5 --- /dev/null +++ b/cli/cmd/enrich.go @@ -0,0 +1,33 @@ +/* +Copyright © 2026 Hector Alfaro +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// enrichCmd represents the enrich command +var enrichCmd = &cobra.Command{ + Use: "enrich", + Short: "🔜 Will look up OL IDs for each book", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("enrich called") + }, +} + +func init() { + rootCmd.AddCommand(enrichCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // enrichCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // enrichCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cli/cmd/storygraph.go b/cli/cmd/import.go similarity index 85% rename from cli/cmd/storygraph.go rename to cli/cmd/import.go index d01be85..b16d2ed 100644 --- a/cli/cmd/storygraph.go +++ b/cli/cmd/import.go @@ -22,12 +22,11 @@ type bookOutput struct { // importCmd represents the import command var importCmd = &cobra.Command{ - Use: "storygraph", + Use: "import", Short: "Import from a StoryGraph CSV", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { filename := args[0] - statusFilter, _ := cmd.Flags().GetString("status") _, csvSuffix := strings.CutSuffix(filename, ".csv") if !csvSuffix { @@ -48,11 +47,6 @@ var importCmd = &cobra.Command{ continue } - statusFilter = lexicon.NormalizeStatus(statusFilter) - if statusFilter != "" && lexStatus != statusFilter { - continue - } - output = append(output, bookOutput{ Book: book, LexiconStatus: lexStatus, @@ -77,5 +71,5 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: // importCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - importCmd.Flags().String("status", "", "Filter by lexicon status") + importCmd.Flags().String("source", "storygraph", "Import source, defaults to storygraph.") } diff --git a/cli/cmd/list.go b/cli/cmd/list.go new file mode 100644 index 0000000..e05361f --- /dev/null +++ b/cli/cmd/list.go @@ -0,0 +1,41 @@ +/* +Copyright © 2026 Hector Alfaro +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" + "tangled.org/hectorsector.com/books/cli/internal/lexicon" +) + +// listCmd represents the list command +var listCmd = &cobra.Command{ + Use: "list", + Short: "List the books in our local record.", + Run: func(cmd *cobra.Command, args []string) { + statusFilter, _ := cmd.Flags().GetString("status") + + statusFilter = lexicon.NormalizeStatus(statusFilter) + fmt.Println("status filter:", statusFilter) + // if statusFilter != "" && lexStatus != statusFilter { + // continue + // } + }, +} + +func init() { + rootCmd.AddCommand(listCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // listCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // listCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + listCmd.Flags().String("status", "", "filter by lexicon status (options: wantToRead, reading, finished, didNotFinish, paused)") +} diff --git a/cli/cmd/publish.go b/cli/cmd/publish.go new file mode 100644 index 0000000..b06f08c --- /dev/null +++ b/cli/cmd/publish.go @@ -0,0 +1,33 @@ +/* +Copyright © 2026 Hector Alfaro +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// publishCmd represents the publish command +var publishCmd = &cobra.Command{ + Use: "publish", + Short: "🔜 Will publish book and status records to a user's PDS", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("publish called") + }, +} + +func init() { + rootCmd.AddCommand(publishCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // publishCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // publishCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/docs/cli-commands.md b/docs/cli-commands.md new file mode 100644 index 0000000..e60d87a --- /dev/null +++ b/docs/cli-commands.md @@ -0,0 +1,15 @@ +books + import + --source storygraph # only source for now, but extensible + + list + --status # filter by lexicon status (finished, reading, etc.) + --published # 🔜 only books pushed to the user's PDS + --unpublished # 🔜 only books not yet pushed to the user's PDS + + enrich # 🔜 look up OL IDs for each book + --dry-run # show what OL IDs would be resolved without writing + + publish # 🔜 publish book and status records to a user's PDS + --dry-run # show what would be created on the PDS + --status # only publish books with this status diff --git a/docs/storygraph-to-lexicon-map.md b/docs/storygraph-to-lexicon-map.md new file mode 100644 index 0000000..80a0b4e --- /dev/null +++ b/docs/storygraph-to-lexicon-map.md @@ -0,0 +1,7 @@ +Storygraph Lexicon +---- ---- +to-read #wantToRead +currently-reading #reading +paused #paused +did-not-finish #didNotFinish +read #finished