// joi/10/juno/ListCommand.java // // // Copyright 2003, Bill Campbell and Ethan Bolker import java.util.*; /** * The Juno shell command to list contents of the current directory. * Usage: *
* list ** * @version 10 */ public class ListCommand extends ShellCommand { // The constructor adds this object to the global table. ListCommand() { super( "list contents of current directory" ); } /** * List contents of the current working directory. * * @param args the remainder of the command line. * @param sh the current shell * * @exception JunoException for reporting errors */ public void doIt( StringTokenizer args, Shell sh ) throws JunoException { OutputInterface terminal = sh.getConsole(); Directory dir = sh.getDot(); String[] fileNames = dir.getFileNames(); terminal.println( dir.getPathName() ); for ( int i = 0; i < fileNames.length; i++ ) { String fileName = fileNames[i]; JFile jfile = dir.retrieveJFile( fileName ); terminal.println( jfile.toString() ); } } }