backstack: have added the workspace flag
This commit is contained in:
		
							parent
							
								
									6c5787b271
								
							
						
					
					
						commit
						cc58db2d49
					
				|  | @ -28,6 +28,7 @@ func main() { | |||
| 	var flagTable = flag.String("t", "", "dynamodb table name") | ||||
| 	var flagLocal = flag.String("local", "", "local endpoint") | ||||
| 	var flagDebug = flag.String("debug", "", "file to log debug messages") | ||||
| 	var flagWorkspace = flag.String("w", "", "workspace file") | ||||
| 	flag.Parse() | ||||
| 
 | ||||
| 	ctx := context.Background() | ||||
|  | @ -37,11 +38,11 @@ func main() { | |||
| 		cli.Fatalf("cannot load AWS config: %v", err) | ||||
| 	} | ||||
| 
 | ||||
| 	wsManager := workspaces.New(workspaces.MetaInfo{ | ||||
| 		Command: "sqs-browse", | ||||
| 	}) | ||||
| 	//ws, err := wsManager.CreateTemp()
 | ||||
| 	ws, err := wsManager.Open("temp.workspace") | ||||
| 	closeFn := logging.EnableLogging(*flagDebug) | ||||
| 	defer closeFn() | ||||
| 
 | ||||
| 	wsManager := workspaces.New(workspaces.MetaInfo{Command: "dynamo-browse"}) | ||||
| 	ws, err := wsManager.OpenOrCreate(*flagWorkspace) | ||||
| 	if err != nil { | ||||
| 		cli.Fatalf("cannot create workspace: %v", ws) | ||||
| 	} | ||||
|  | @ -83,9 +84,6 @@ func main() { | |||
| 
 | ||||
| 	p := tea.NewProgram(model, tea.WithAltScreen()) | ||||
| 
 | ||||
| 	closeFn := logging.EnableLogging(*flagDebug) | ||||
| 	defer closeFn() | ||||
| 
 | ||||
| 	// Pre-determine if layout has dark background.  This prevents calls for creating a list to hang.
 | ||||
| 	if lipgloss.HasDarkBackground() { | ||||
| 		if colorScheme := osstyle.CurrentColorScheme(); colorScheme == osstyle.ColorSchemeLightMode { | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ package workspaces | |||
| import ( | ||||
| 	"github.com/asdine/storm" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"log" | ||||
| 	"os" | ||||
| ) | ||||
| 
 | ||||
|  | @ -18,11 +19,19 @@ func New(metaInfo MetaInfo) *Manager { | |||
| 	return &Manager{metainfo: metaInfo} | ||||
| } | ||||
| 
 | ||||
| func (m *Manager) OpenOrCreate(filename string) (*Workspace, error) { | ||||
| 	if filename == "" { | ||||
| 		return m.CreateTemp() | ||||
| 	} | ||||
| 	return m.Open(filename) | ||||
| } | ||||
| 
 | ||||
| func (m *Manager) Open(filename string) (*Workspace, error) { | ||||
| 	db, err := storm.Open(filename) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.Wrapf(err, "cannot open workspace at %v", filename) | ||||
| 	} | ||||
| 	log.Printf("open workspace: %v", filename) | ||||
| 	return &Workspace{db: db}, nil | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue