Loading dclish/dclish.go +14 −9 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ type Flag struct { Value string Default string Description string // TODO: Toggle bool } // Flags is the list of flags. Loading @@ -22,7 +23,10 @@ type Flags map[string]*Flag // Command contains the definition of a command, it's flags and subcommands. type Command struct { Flags Flags // TODO: FlagOrder []string Args []string // TODO: MaxArgs int // TODO: MinArgs int Commands []*Command Action ActionFunc Description string Loading Loading @@ -52,18 +56,19 @@ func (c Commands) ParseAndRun(line string) error { return cmd.Action(cmd) } // TODO: need to clean this up. for i := range words[1:] { if strings.HasPrefix(words[i], "/") { flag, val, assigned := strings.Cut(words[i], "=") args := words[1:] for i := range args { if strings.HasPrefix(args[i], "/") { flag, val, assigned := strings.Cut(args[i], "=") if assigned { wordup := strings.ToUpper(flag) flg, ok := cmd.Flags[wordup] if !ok { fmt.Printf("ERROR: Flag '%s' not recognised.", words[i]) fmt.Printf("ERROR: Flag '%s' not recognised.", args[i]) } flg.Value = val } else { wordup := strings.ToUpper(words[i]) wordup := strings.ToUpper(args[i]) value := "true" if strings.HasPrefix(wordup, "/NO") { wordup = strings.Replace(wordup, "/NO", "/", 1) Loading @@ -71,12 +76,12 @@ func (c Commands) ParseAndRun(line string) error { } flg, ok := cmd.Flags[wordup] if !ok { fmt.Printf("ERROR: Flag '%s' not recognised.", words[i]) fmt.Printf("ERROR: Flag '%s' not recognised.", args[i]) } flg.Value = value } } else { cmd.Args = append(cmd.Args, words[i]) cmd.Args = append(cmd.Args, args[i]) } } return cmd.Action(cmd) Loading repl/command.go +0 −57 Original line number Diff line number Diff line Loading @@ -552,17 +552,6 @@ folder at the other node is also a SYSTEM folder. }, }, }, "Ctrl-C": { Description: `Except for when BULLETIN is awaiting input from the terminal, a CTRL-C will cause BULLETIN to abort the execution of any command. If BULLETIN is waiting for terminal input, a CTRL-C will cause BULLETIN to return to the BULLETIN> prompt. If for some reason the user wishes to suspend BULLETIN, CTRL-Y will usually do so. However, this is not always true, as BULLETIN will ignore the CTRL-Y if it has a data file opened at the time. (Otherwise it would be possible to put the files in a state such that they would be inaccessible by other users.) `, }, "CURRENT": { Description: `Displays the beginning of the message you are currently reading. If you are reading a long message and want to display the first part Loading Loading @@ -835,52 +824,6 @@ file exists, the file would be appended to that file. }, "FORWARD": { Description: `Synonym for MAIL command. `, }, "Folders": { Description: `All messages are divided into separate folders. The default folder is GENERAL. New folders can be created by any user. As an example, the following creates a folder for GAMES related messages: BULLETIN> CREATE GAMES Enter a one line description of folder. GAMES To see the list of available folders, use DIRECTORY/FOLDERS. To select a specific folder, use the SELECT command. If a user selects a folder and enters the SET READNEW command, that user will be alerted of topics of new messages at login time, and will then be given the option of reading them. Similar to READNEW is SHOWNEW, which displays the topics but doesn't prompt to read them. Even less is SET BRIEF, which will cause only a one line output indicating that there are new messages in the folder. There also is the SET NOTIFY option, which will cause a message to be broadcast to a user's terminal alerting the user that a new message has been added. Any of these options can be the default for the folder by using the /DEFAULT switch on the command. A folder can be restricted to only certain users, if desired. This is done by specifying CREATE/PRIVATE. Afterwards, access to the folder is controlled by the creator by the SET [NO]ACCESS command. If /SEMIPRIVATE rather than /PRIVATE is specified, all users can read the messages in the folder, but only those give access can add messages. A folder can be converted into a remote folder using CREATE/NODE or SET NODE. A remote folder is one which points to a folder on a remote DECNET node. Messages added to a remote node are actually stored on the folder on the remote node. The BULLCP process (created by BULLETIN/STARTUP) must be running on the remote node for this option to be used. A folder can be specified as a SYSTEM folder, i.e. one in which SYSTEM/ SHUTDOWN/BROADCAST messages can be added. By default, the GENERAL folder is a SYSTEM folder (and cannot be changed). One use for this is to create a remote SYSTEM folder which is shared by all nodes, so that the GENERAL folder is used for messages pertaining only to the local host, while the remote folder is used for messages pertaining to all nodes. Another use is to create a folder for posting SYSTEM messages only meant for a certain UIC group. This is done by creating a PRIVATE SYSTEM folder, and giving access to that UIC group. Only users in that UIC group will see the messages in that folder when they log in. `, }, "HELP": { Loading repl/help.go +60 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,66 @@ import ( "git.lyda.ie/kevin/bulletin/dclish" ) var helpmap map[string]string var helpmap = map[string]string{ "FOLDERS": `All messages are divided into separate folders. The default folder is GENERAL. New folders can be created by any user. As an example, the following creates a folder for GAMES related messages: BULLETIN> CREATE GAMES Enter a one line description of folder. GAMES To see the list of available folders, use DIRECTORY/FOLDERS. To select a specific folder, use the SELECT command. If a user selects a folder and enters the SET READNEW command, that user will be alerted of topics of new messages at login time, and will then be given the option of reading them. Similar to READNEW is SHOWNEW, which displays the topics but doesn't prompt to read them. Even less is SET BRIEF, which will cause only a one line output indicating that there are new messages in the folder. There also is the SET NOTIFY option, which will cause a message to be broadcast to a user's terminal alerting the user that a new message has been added. Any of these options can be the default for the folder by using the /DEFAULT switch on the command. A folder can be restricted to only certain users, if desired. This is done by specifying CREATE/PRIVATE. Afterwards, access to the folder is controlled by the creator by the SET [NO]ACCESS command. If /SEMIPRIVATE rather than /PRIVATE is specified, all users can read the messages in the folder, but only those give access can add messages. A folder can be converted into a remote folder using CREATE/NODE or SET NODE. A remote folder is one which points to a folder on a remote DECNET node. Messages added to a remote node are actually stored on the folder on the remote node. The BULLCP process (created by BULLETIN/STARTUP) must be running on the remote node for this option to be used. A folder can be specified as a SYSTEM folder, i.e. one in which SYSTEM/ SHUTDOWN/BROADCAST messages can be added. By default, the GENERAL folder is a SYSTEM folder (and cannot be changed). One use for this is to create a remote SYSTEM folder which is shared by all nodes, so that the GENERAL folder is used for messages pertaining only to the local host, while the remote folder is used for messages pertaining to all nodes. Another use is to create a folder for posting SYSTEM messages only meant for a certain UIC group. This is done by creating a PRIVATE SYSTEM folder, and giving access to that UIC group. Only users in that UIC group will see the messages in that folder when they log in.`, "Ctrl-C": `Except for when BULLETIN is awaiting input from the terminal, a CTRL-C will cause BULLETIN to abort the execution of any command. If BULLETIN is waiting for terminal input, a CTRL-C will cause BULLETIN to return to the BULLETIN> prompt. If for some reason the user wishes to suspend BULLETIN, CTRL-Y will usually do so. However, this is not always true, as BULLETIN will ignore the CTRL-Y if it has a data file opened at the time. (Otherwise it would be possible to put the files in a state such that they would be inaccessible by other users.) `, } func init() { for c := range commands { helpmap[c] = commands[c].Description } } // ActionHelp handles the `HELP` command. func ActionHelp(cmd *dclish.Command) error { Loading @@ -19,7 +78,6 @@ func ActionHelp(cmd *dclish.Command) error { wordup := strings.ToUpper(cmd.Args[0]) helptext, ok := helpmap[wordup] if !ok { // TODO: add a help structure for topics that are not command. fmt.Printf("ERROR: Topic not found: '%s'.\n", cmd.Args[0]) return nil } Loading Loading
dclish/dclish.go +14 −9 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ type Flag struct { Value string Default string Description string // TODO: Toggle bool } // Flags is the list of flags. Loading @@ -22,7 +23,10 @@ type Flags map[string]*Flag // Command contains the definition of a command, it's flags and subcommands. type Command struct { Flags Flags // TODO: FlagOrder []string Args []string // TODO: MaxArgs int // TODO: MinArgs int Commands []*Command Action ActionFunc Description string Loading Loading @@ -52,18 +56,19 @@ func (c Commands) ParseAndRun(line string) error { return cmd.Action(cmd) } // TODO: need to clean this up. for i := range words[1:] { if strings.HasPrefix(words[i], "/") { flag, val, assigned := strings.Cut(words[i], "=") args := words[1:] for i := range args { if strings.HasPrefix(args[i], "/") { flag, val, assigned := strings.Cut(args[i], "=") if assigned { wordup := strings.ToUpper(flag) flg, ok := cmd.Flags[wordup] if !ok { fmt.Printf("ERROR: Flag '%s' not recognised.", words[i]) fmt.Printf("ERROR: Flag '%s' not recognised.", args[i]) } flg.Value = val } else { wordup := strings.ToUpper(words[i]) wordup := strings.ToUpper(args[i]) value := "true" if strings.HasPrefix(wordup, "/NO") { wordup = strings.Replace(wordup, "/NO", "/", 1) Loading @@ -71,12 +76,12 @@ func (c Commands) ParseAndRun(line string) error { } flg, ok := cmd.Flags[wordup] if !ok { fmt.Printf("ERROR: Flag '%s' not recognised.", words[i]) fmt.Printf("ERROR: Flag '%s' not recognised.", args[i]) } flg.Value = value } } else { cmd.Args = append(cmd.Args, words[i]) cmd.Args = append(cmd.Args, args[i]) } } return cmd.Action(cmd) Loading
repl/command.go +0 −57 Original line number Diff line number Diff line Loading @@ -552,17 +552,6 @@ folder at the other node is also a SYSTEM folder. }, }, }, "Ctrl-C": { Description: `Except for when BULLETIN is awaiting input from the terminal, a CTRL-C will cause BULLETIN to abort the execution of any command. If BULLETIN is waiting for terminal input, a CTRL-C will cause BULLETIN to return to the BULLETIN> prompt. If for some reason the user wishes to suspend BULLETIN, CTRL-Y will usually do so. However, this is not always true, as BULLETIN will ignore the CTRL-Y if it has a data file opened at the time. (Otherwise it would be possible to put the files in a state such that they would be inaccessible by other users.) `, }, "CURRENT": { Description: `Displays the beginning of the message you are currently reading. If you are reading a long message and want to display the first part Loading Loading @@ -835,52 +824,6 @@ file exists, the file would be appended to that file. }, "FORWARD": { Description: `Synonym for MAIL command. `, }, "Folders": { Description: `All messages are divided into separate folders. The default folder is GENERAL. New folders can be created by any user. As an example, the following creates a folder for GAMES related messages: BULLETIN> CREATE GAMES Enter a one line description of folder. GAMES To see the list of available folders, use DIRECTORY/FOLDERS. To select a specific folder, use the SELECT command. If a user selects a folder and enters the SET READNEW command, that user will be alerted of topics of new messages at login time, and will then be given the option of reading them. Similar to READNEW is SHOWNEW, which displays the topics but doesn't prompt to read them. Even less is SET BRIEF, which will cause only a one line output indicating that there are new messages in the folder. There also is the SET NOTIFY option, which will cause a message to be broadcast to a user's terminal alerting the user that a new message has been added. Any of these options can be the default for the folder by using the /DEFAULT switch on the command. A folder can be restricted to only certain users, if desired. This is done by specifying CREATE/PRIVATE. Afterwards, access to the folder is controlled by the creator by the SET [NO]ACCESS command. If /SEMIPRIVATE rather than /PRIVATE is specified, all users can read the messages in the folder, but only those give access can add messages. A folder can be converted into a remote folder using CREATE/NODE or SET NODE. A remote folder is one which points to a folder on a remote DECNET node. Messages added to a remote node are actually stored on the folder on the remote node. The BULLCP process (created by BULLETIN/STARTUP) must be running on the remote node for this option to be used. A folder can be specified as a SYSTEM folder, i.e. one in which SYSTEM/ SHUTDOWN/BROADCAST messages can be added. By default, the GENERAL folder is a SYSTEM folder (and cannot be changed). One use for this is to create a remote SYSTEM folder which is shared by all nodes, so that the GENERAL folder is used for messages pertaining only to the local host, while the remote folder is used for messages pertaining to all nodes. Another use is to create a folder for posting SYSTEM messages only meant for a certain UIC group. This is done by creating a PRIVATE SYSTEM folder, and giving access to that UIC group. Only users in that UIC group will see the messages in that folder when they log in. `, }, "HELP": { Loading
repl/help.go +60 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,66 @@ import ( "git.lyda.ie/kevin/bulletin/dclish" ) var helpmap map[string]string var helpmap = map[string]string{ "FOLDERS": `All messages are divided into separate folders. The default folder is GENERAL. New folders can be created by any user. As an example, the following creates a folder for GAMES related messages: BULLETIN> CREATE GAMES Enter a one line description of folder. GAMES To see the list of available folders, use DIRECTORY/FOLDERS. To select a specific folder, use the SELECT command. If a user selects a folder and enters the SET READNEW command, that user will be alerted of topics of new messages at login time, and will then be given the option of reading them. Similar to READNEW is SHOWNEW, which displays the topics but doesn't prompt to read them. Even less is SET BRIEF, which will cause only a one line output indicating that there are new messages in the folder. There also is the SET NOTIFY option, which will cause a message to be broadcast to a user's terminal alerting the user that a new message has been added. Any of these options can be the default for the folder by using the /DEFAULT switch on the command. A folder can be restricted to only certain users, if desired. This is done by specifying CREATE/PRIVATE. Afterwards, access to the folder is controlled by the creator by the SET [NO]ACCESS command. If /SEMIPRIVATE rather than /PRIVATE is specified, all users can read the messages in the folder, but only those give access can add messages. A folder can be converted into a remote folder using CREATE/NODE or SET NODE. A remote folder is one which points to a folder on a remote DECNET node. Messages added to a remote node are actually stored on the folder on the remote node. The BULLCP process (created by BULLETIN/STARTUP) must be running on the remote node for this option to be used. A folder can be specified as a SYSTEM folder, i.e. one in which SYSTEM/ SHUTDOWN/BROADCAST messages can be added. By default, the GENERAL folder is a SYSTEM folder (and cannot be changed). One use for this is to create a remote SYSTEM folder which is shared by all nodes, so that the GENERAL folder is used for messages pertaining only to the local host, while the remote folder is used for messages pertaining to all nodes. Another use is to create a folder for posting SYSTEM messages only meant for a certain UIC group. This is done by creating a PRIVATE SYSTEM folder, and giving access to that UIC group. Only users in that UIC group will see the messages in that folder when they log in.`, "Ctrl-C": `Except for when BULLETIN is awaiting input from the terminal, a CTRL-C will cause BULLETIN to abort the execution of any command. If BULLETIN is waiting for terminal input, a CTRL-C will cause BULLETIN to return to the BULLETIN> prompt. If for some reason the user wishes to suspend BULLETIN, CTRL-Y will usually do so. However, this is not always true, as BULLETIN will ignore the CTRL-Y if it has a data file opened at the time. (Otherwise it would be possible to put the files in a state such that they would be inaccessible by other users.) `, } func init() { for c := range commands { helpmap[c] = commands[c].Description } } // ActionHelp handles the `HELP` command. func ActionHelp(cmd *dclish.Command) error { Loading @@ -19,7 +78,6 @@ func ActionHelp(cmd *dclish.Command) error { wordup := strings.ToUpper(cmd.Args[0]) helptext, ok := helpmap[wordup] if !ok { // TODO: add a help structure for topics that are not command. fmt.Printf("ERROR: Topic not found: '%s'.\n", cmd.Args[0]) return nil } Loading