feat: add project export and import functionality
- Implemented `pcli project export` command to export project hierarchy as JSON. - Added `pcli project import` command to import project data from JSON. - Created user client to fetch user details for comment attribution. - Introduced new data structures for export and import processes. - Ensured name-based references in exports and handled conflicts during imports. - Added versioning and progress reporting for import operations. - Updated documentation and specifications for new features.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var projectExportCmd = &cobra.Command{
|
||||
Use: "export <project-id-or-name>",
|
||||
Short: "Export a project to JSON",
|
||||
Long: "Export a project (or a specific board) as a portable JSON file to stdout",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
boardFilter, _ := cmd.Flags().GetString("board")
|
||||
|
||||
projectID, err := resolveProject(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
envelope, err := getClient().ExportProject(getContext(), projectID, boardFilter)
|
||||
if err != nil {
|
||||
return friendlyAPIError(err, "export project", "")
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(os.Stdout)
|
||||
encoder.SetIndent("", " ")
|
||||
if err := encoder.Encode(envelope); err != nil {
|
||||
return fmt.Errorf("failed to encode export: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectExportCmd)
|
||||
projectExportCmd.Flags().String("board", "", "Filter to a specific board (name or ID)")
|
||||
}
|
||||
Reference in New Issue
Block a user