specialcmd

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package specialcmd handles special (aka. "magic") commands, that come in two flavors:

  • `%<cmd> {...args...}`: Control the environment (variables) and configure gonb.
  • `!<shell commands>`: Execute shell commands. Similar to the ipython kernel.

In particular `%help` will print out currently available commands.

Index

Constants

View Source
const MillisecondsWaitForInput = 200

MillisecondsWaitForInput is the wait time for a bash script (started with `!` or `!*` special commands, when `%with_inputs` or `%with_password` is used) to run, before an input is prompted to the Jupyter Notebook.

Variables

View Source
var (
	CellSpecialCommands = SetWithValues(
		"%%writefile",
		"%%script",
		"%%bash",
		"%%sh",
		"%%gx",
	)
)
View Source
var HelpMessage string

Functions

func ExecuteSpecialCell added in v0.10.0

func ExecuteSpecialCell(msg kernel.Message, goExec *goexec.State, lines []string) (isSpecialCell bool, err error)

ExecuteSpecialCell checks whether it is a special cell (see CellSpecialCommands), and if so it executes the special cell command.

It returns if this was a special cell (if true it executes it), and potentially an execution error, if one happened.

func IsGoCell added in v0.10.0

func IsGoCell(firstLine string) bool

IsGoCell returns whether the cell is expected to be a Go cell, based on the first line.

The first line may contain special commands that change the interpretation of the cell, e.g.: "%%script", "%%writefile".

func Parse

func Parse(msg kernel.Message, goExec *goexec.State, execute bool, codeLines []string, usedLines Set[int]) (err error)

Parse will check whether the given code to be executed has any special commands.

Any special commands found in the code will be executed (if execute is set to true) and the corresponding lines used from the code will be returned in usedLines -- so they can be excluded from other executors (goexec).

If any errors happen, it is returned in err.

Types

This section is empty.

Jump to

Keyboard shortcuts

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