workspace

package
v0.0.0-...-951143b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2023 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MagicWorkspaceDirname = ".ipld"

Variables

View Source
var Cmd_Workspace = &cli.Command{
	Name:     "workspace",
	Category: "basic",
	Usage:    "Create, configure, or interogate a workspace for the ipldtool.  (You'll need a workspace for any of the stateful commands.)",
	Subcommands: []*cli.Command{{
		Name:   "new",
		Usage:  "Creates the local filesystem markers for a new workspace.",
		Flags:  []cli.Flag{},
		Action: Action_WorkspaceNew,
	}, {
		Name:   "find",
		Usage:  "Tells you what the current workspace is.",
		Action: Action_WorkspaceFind,
	}},
}

Functions

func Action_WorkspaceFind

func Action_WorkspaceFind(args *cli.Context) error

Action_WorkspaceFind is the 'ipld workspace find' command. It prints out the path to the workspace, or nothing if one isn't found.

Errors:

  • ipldtool-error-invalid-args -- for incomprehensible or invalid arguments.
  • ipldtool-error-no-cwd -- if the cwd can't be found!
  • ipldtool-error-io -- if there's an io error (permission denied, readonly disk, etc).
  • ipldtool-workspace-not-found -- FIXME: this isn't actually possible.

It is not an error if the workspace already exists.

func Action_WorkspaceNew

func Action_WorkspaceNew(args *cli.Context) error

Action_WorkspaceNew is the 'ipld workspace new' command.

Errors:

  • ipldtool-error-invalid-args -- for incomprehensible or invalid arguments.
  • ipldtool-error-io -- if there's an io error (permission denied, readonly disk, etc).

It is not an error if the workspace already exists.

func Find

func Find() (string, error)

Find the nearest workspace, based on search around cwd and env vars.

The string returned is a path to a directory that contains an '.ipld' directory. (E.g. the string returned does not include the '.ipld' segment itself.)

The search operations, in order, are:

  • accept an env var overriding it: `$IPLDTOOL_WORKSPACE`.
  • look at the present dir so see if it contains an `.ipld` dir.
  • look at parent dirs, recursively, to see if it contains an `.ipld` dir.
  • if nothing is found yet: if `$IPLDTOOL_NOHOME` is set, stop, none found. (Necessary to have an option for this so we can handle readonly fs without a fuss.)
  • fallback to `$HOME/.ipld` as a workspace (even if we have to create it).

Edge cases: if the '.ipld' path exists, but is a file, we don't comment on it. (You should get errors from subsequent operations that are informative enough anyway.) If we fell back to an '.ipld' dir in the user homedir, this function may create it.

Errors:

  • ipldtool-workspace-not-found -- if we tried everything and can't find a workspace.
  • ipldtool-error-no-cwd -- if the cwd can't be found!
  • ipldtool-error-io -- if there's an io error during the search (permission denied, etc).

func FindFrom

func FindFrom(startAt string) (string, error)

FindFrom is the same as Find, but when searching, starts at the directory of your choosing.

Errors:

  • ipldtool-workspace-not-found -- if we tried everything and can't find a workspace.
  • ipldtool-error-io -- if there's an io error during the search (permission denied, etc).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL